Skip to content

keeper: fix atomix writes. #495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2018
Merged

Conversation

sgotti
Copy link
Member

@sgotti sgotti commented May 28, 2018

The current atomic write functions inside pkg/postgresql are missing some error
checks and don't close the file before renaming. Improve common.WriteFileAtomic
to be able to stream writes and use it.

@nh2
Copy link
Contributor

nh2 commented May 28, 2018

I see now what you mean with the missing error checks in f.WriteString():

f.WriteString(fmt.Sprintf("%s = '%s'\n", n, v)) in WriteRecoveryConf should have _, err = left of it.

I'm a bit annoyed at myself though, because I stared at that line for a long time and still didn't spot it.

I guess go makes it very easy to forget to check errors for functions that don't return values you need.

Change looks good to me!

@nh2
Copy link
Contributor

nh2 commented May 28, 2018

@sgotti What do you think about using a linter like https://github.com/kisielk/errcheck that promises to find all unused errors returned by functions?

@sgotti
Copy link
Member Author

sgotti commented May 28, 2018

@nh2 Thanks for the review!

@sgotti What do you think about using a linter like https://github.com/kisielk/errcheck that promises to find all unused errors returned by functions?

Sure, will try to add it in another PR. Just noticed that my VIM setup with ALE + gometalinter isn't working since it should have reported it...

The current atomic write functions inside pkg/postgresql are missing some error
checks and don't close the file before renaming. Improve common.WriteFileAtomic
to be able to stream writes and use it.
@sgotti sgotti force-pushed the keeper_fix_atomic_writes branch from 14cff0c to 3790f9e Compare May 29, 2018 07:25
@sgotti sgotti merged commit 3790f9e into sorintlab:master May 29, 2018
sgotti added a commit that referenced this pull request May 29, 2018
@sgotti sgotti added this to the v0.11.0 milestone Jun 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants