-
Notifications
You must be signed in to change notification settings - Fork 446
Restart postgres if required when updating pgParameters #568
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
Restart postgres if required when updating pgParameters #568
Conversation
437b807
to
385a109
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmd/keeper/cmd/keeper.go
Outdated
@@ -1588,6 +1589,17 @@ func (p *PostgresKeeper) postgresKeeperSM(pctx context.Context) { | |||
if err := pgm.Reload(); err != nil { | |||
log.Errorw("failed to reload postgres instance", err) | |||
} | |||
needsRestart, err := pgm.IsRestartRequired(changedParams) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a not for a future improvement (will prefer doing this in a separate PR): we could report the need restart in the PostgresState reported to the sentinel so it could be showed in the stolonctl status
output for people that won't enable automatic restart (see below comment).
cmd/keeper/cmd/keeper.go
Outdated
log.Errorw("Failed to checked if restart is required", err) | ||
} | ||
|
||
if needsRestart { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make this opt in adding an option in the cluster spec. I'll leave it disabled by default (at least for the moment, to not break current expected behavior and avoid possible issue when users provides a wrong parameter that will break instance restart)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sgotti As you suggested, We will make the pgRestart optional(disbaled by default) and add some integration tests. We will try to close this by this weekend.
cc @aswinkarthik
@prabhu43 gentle ping. |
7d4c530
to
de1ad5e
Compare
ce79c57
to
659359c
Compare
Hi @sgotti We added Integration test. However, we are not able to debug why it is failing exactly. The logs are too verbose. Could you give us some pointers? Also we found it difficult to run it locally. Are there any docs for doing so? |
Great!
You should fetch the output log from semaphore and search for
We just do the same that is done on semaphore: For example to test with the locally installed postgres using etcdv3 backend:
You can also parallelize (if you have fast disks):
Or use a tmpfs if you have a lot of ram as I do:
so the tests will complete in ~2 minutes. |
9978016
to
f9c1ba8
Compare
f9c1ba8
to
4daa9a3
Compare
Co-authored-by: Aswin Karthik <aswinkarthik93@gmail.com>
4daa9a3
to
531df56
Compare
@sgotti The integartion test is done. Could you review the commit? |
@aswinkarthik Great! Will review tomorrow. |
@prabhu43 Looks good to me! Just noticed a behavior that I'm not sure how to deal with:
I don't see this as a big deal and the behavior could be improved in a next PR if needed. What do you think? We should also update the related doc:
We can also add this in a separate PR. Let me know what you prefer. |
@sgotti We felt that the intent of "automaticPgRestart" is to do postgres restart only when it is required which is on changing some pgParameters. We will add update the docs in this PR itself. |
e95bc59
to
b5d34ae
Compare
Co-authored-by: Prabhu Jayakumar <j.prabhu91@gmail.com> Signed-off-by: Aswin Karthik <aswinkarthik93@gmail.com>
b5d34ae
to
b62fc6e
Compare
I have updated documentation @sgotti |
Regarding this, there is a slight inconsistency here based on Postgres version. 9.5 and after: If For 9.4 and lower: If |
@sgotti We updated the docs with required details. Can you review those changes and merge the PR ? |
@prabhu43 @aswinkarthik LGTM. Merging. Thanks a lot! |
Restart postgres if required when updating pgParameters
@sgotti Thanks for merging. When can we expect this to be released? |
Alternate approach that. Fixes #88
Context:
If some postgres configurations (pgParameters) that require restart are updated, a restart is triggered
Approach:
For Postgres versions >= 9.5,
pg_settings
table haspending_restarts
9.5 pg_settings reference
For older versions of postgres,
pg_settings
'scontext
9.4 pg_settings reference