postgresql icon indicating copy to clipboard operation
postgresql copied to clipboard

Only restart the cluster when absolutely necessary, otherwise reload

Open gclough opened this issue 6 years ago • 20 comments

Only restart the cluster when absolutely necessary, otherwise do a reload. Default to mega safety, and even if a restart is needed, then only do so if the "postgresql_restart_on_config_change" variable is set to true (default false)

Most normal parameter changes will simply "reload" the cluster, meaning no downtime.

Fixes #291

gclough avatar Mar 09 '18 17:03 gclough

Good point

erdenezul avatar Mar 09 '18 23:03 erdenezul

@gclough In my previous company we have solved issue with restarting PostgreSQL by creating template file with options, setting which requires restart. And then call handler to restart Postgres only if file changed and reload in other way.

UnderGreen avatar Mar 10 '18 15:03 UnderGreen

I did consider that @UnderGreen , but I thought that leveraging the built-in functionality of the pg_settings(pending_restart) column would be more stable going forward. It also allows us to have all of the settings in a single template, just to keep things simple.

The only downside is that it doesn't work for v9.4 and earlier... although I figured that's an acceptable trade-off, and possibly an encouragement for those on older versions to upgrade. v9.4 is End of Life in Dec/2019, so there are only 20 months until it's obsolete.

gclough avatar Mar 12 '18 10:03 gclough

Closing to re-trigger Travis

gclough avatar Apr 03 '18 09:04 gclough

@sebalix , @UnderGreen, and @jlozadad ... this touches so much of the role so merging in recent changes has been a bit messy. I think I've squashed the commits as you wanted, but if I'm doing it wrong then please let me know.

I would appreciate a code review on this, and I will put in comments anywhere it's a bit unclear.

gclough avatar Apr 04 '18 10:04 gclough

the vagrant changes you added are alrdy on master so those are not needed.

aoyawale avatar Apr 04 '18 11:04 aoyawale

you might have to start making smaller PRs since it would be easier to go through.

aoyawale avatar Apr 04 '18 11:04 aoyawale

i think it would be easier if you do a PR with only what fixed the travis build peer auth part. that way we can merge that part and fix it in the other PRs.

aoyawale avatar Apr 04 '18 11:04 aoyawale

when you do include_tasks it does not grab the restart.yml automatically? i dont think u need to specify a role path.

aoyawale avatar Apr 04 '18 12:04 aoyawale

@jlozadad

the vagrant changes you added are alrdy on master so those are not needed.

Yeah, I think I messed up my rebase, but after I had resolved the conflicts then it removed those from the "Changed Files" tab. Hopefully it's all looking better now.

you might have to start making smaller PRs since it would be easier to go through.

I think this one looked huge due to my rebase error, but now I've merged it with master it seems to be much smaller.

i think it would be easier if you do a PR with only what fixed the travis build peer auth part. that way we can merge that part and fix it in the other PRs.

After I fixed the rebase error, I think it's now only got the changes necessary for this fix, which was to avoid doing any restart unless it's necessary. Yes, it did fiddle with the handlers a lot, but that was needed to achieve the logic of restart/reload and multiple different versions with differing capabilities.

when you do include_tasks it does not grab the restart.yml automatically? i dont think u need to specify a role path.

That's what I tried, but it failed because it couldn't find the file. Initially I was using import_tasks without any path... but that part of Ansible seems to be a little bit broken.

gclough avatar Apr 04 '18 12:04 gclough

no problem. i had that happen the other too :)

aoyawale avatar Apr 04 '18 16:04 aoyawale

i think its better if you add what you have in reload.yml and put on main.yml and remove the role path. you can still call the handler from there.

aoyawale avatar Apr 12 '18 01:04 aoyawale

for psql queries i think we can leverage https://github.com/rtshome/ansible_pgsql from the lib dir and use those and avoid shell/command since it can get dirty quickly.

aoyawale avatar Apr 12 '18 01:04 aoyawale

@jlozadad ... the use of pgsql seems pretty common in this role, but I've opened #339 to try and make that module work. It seems to work locally, but we will then have a pre-requisite before folks can use the ANXS.postgresl role.

Is there a better way to do this?

gclough avatar Apr 12 '18 17:04 gclough

so what we can do is not copy the role and everything they have but, create a library directory under this role and copy the *py files over. Its just a though at this moment since I have not tested using them with this role. But, it can be a great improvement since they are actual ansible modules.

aoyawale avatar Apr 12 '18 20:04 aoyawale

@jlozadad ... I was trying not to copy in their role wholesale, as then I'd be responsible to maintain it and update ANXS.postgresql whenever it changes. If there's a standard way to just "import" a role, then I'd prefer to do it that way.

gclough avatar Apr 13 '18 15:04 gclough

Guys, did you think about tech diligence of that modules? I know python, but don't have a time to review. We should not use modules without any review.

UnderGreen avatar Apr 13 '18 15:04 UnderGreen

that is why I mentioned It will need to be tested and checked more. Also as a potential solution.

aoyawale avatar Apr 13 '18 16:04 aoyawale

@gclough you don't have to import role or do anything of that nature. If you are adding modules all you need is the *.py files in the libraries directory on this role. But, like mentioned this was just a though and not a "we need to do this now"

aoyawale avatar Apr 13 '18 16:04 aoyawale

OK @UnderGreen and @jlozadad ... it sounds like we should continue with the "shell / command", and then potentially replace it with ansible_pgsql in a separate Pull Request, if and when we're comfortable with it.

Does that sound sensible? This is a reasonably large PR, so if you have any questions then please let me know. IMHO it's very beneficial, because as it stands any small change in the *.conf files will result in unnecessary downtime on the database.

gclough avatar Apr 14 '18 09:04 gclough

This pr has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

github-actions[bot] avatar Apr 27 '24 23:04 github-actions[bot]