Skip to content

keeper: fix atomix writes.#495

Merged
sgotti merged 1 commit into
sorintlab:masterfrom
sgotti:keeper_fix_atomic_writes
May 29, 2018
Merged

keeper: fix atomix writes.#495
sgotti merged 1 commit into
sorintlab:masterfrom
sgotti:keeper_fix_atomic_writes

Conversation

@sgotti

@sgotti sgotti commented May 28, 2018

Copy link
Copy Markdown
Member

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

nh2 commented May 28, 2018

Copy link
Copy Markdown
Contributor

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

nh2 commented May 28, 2018

Copy link
Copy Markdown
Contributor

@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

sgotti commented May 28, 2018

Copy link
Copy Markdown
Member Author

@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