Skip to content
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

[feature] Avoid unnecessary restart when postgresql.conf changes #41

Open
willthames opened this issue Nov 4, 2015 · 4 comments
Open

Comments

@willthames
Copy link
Contributor

Most postgresql.conf changes don't need a restart, just a reload. And a reload is much safer.

To avoid a restart except where essential, there are a few approaches.
One is documented at http://www.postgresql.org/message-id/[email protected]

My thought was to have postgresql.conf only include postgresql_needs_restart.conf and postgresql_needs_reload.conf. postgresql_needs_restart.conf would include the parameters mentioned in the above email thread.

If postgresql.conf or postgresql_needs_restart.conf changes, the restart postgresql handler is fired as now. But if postgresql_needs_reload.conf changes, a new reload postgresql handler is fired.

I'm happy to implement this but thought I'd see what your thoughts were first on whether it's a sensible approach or if there's anything I've missed.

@Trikke76
Copy link
Contributor

Trikke76 commented Nov 6, 2015

It will ask a bit of implementation but would indeed be a great addition to the rule imho.
I don't know what others are thinking about this but for me it looks awesome
next week i'm rather busy but after that i could probably help implementing this rule if you want some help on this.

Anyone else any toughts ? maybe on negative impacts it might have that i am missing ?

@ciphernaut
Copy link
Contributor

meta/main.yml:
postgresql_need_full_postgresql_restart: False


tasks/configure.yml"

  • name: foo
    register: something_fundamental
  • set_fact: postgresql_need_full_postgresql_restart=True
    when: something_fundamental|changed

handlers/main/yml:

  • name: restart postgresql
    shell: /bin/true #(needed for ansible v1.9)
    always_run: true
    notify: restart postgresql full
    notify: restart postgresql soft
  • name: restart postgresql full
    service: name=postgresql{{join_char | default("-")}}{{postgresql_version}} state=restarted
    when: postgresql_need_full_postgresql_restart
  • name: restart postgresql soft
    service: name=postgresql{{join_char | default("-")}}{{postgresql_version}} state=reloaded
    when: not postgresql_need_full_postgresql_restart

@willthames
Copy link
Contributor Author

Trouble is working out something_fundamental. Some things in postgresql.conf need a restart, most just need a reload.

postgresql_need_full_postgresql_restart should presumably be in defaults/main.yml, not meta/main.yml

Also, notify takes a list (two notify keys would just mean one is ignored)

python -c 'import yaml; d = "test_dict:\n  notify: one\n  notify: two"; y = yaml.load(d); print y'
{'test_dict': {'notify': 'two'}}

I'm not convinced the logic is any easier - I'd just notify a full restart when something fundamental changed, and a reload otherwise.

@Trikke76
Copy link
Contributor

hey 

Thx for all the contributions

I will try to test en merge in the coming weeks

On holiday now till end of next week ...

Patrik

-----Original message-----
From: Will Thames [email protected]
Sent: Friday 26th February 2016 7:25
To: Open-Future-Belgium/PostgreSQL [email protected]
Cc: Patrik Uytterhoeven [email protected]
Subject: Re: [PostgreSQL] [feature] Avoid unnecessary restart when postgresql.conf changes (#41)

Trouble is working out something_fundamental. Some things in postgresql.conf need a restart, most just need a reload.

postgresql_need_full_postgresql_restart should presumably be in defaults/main.yml, not meta/main.yml

Also, notify takes a list (two notify keys would just mean one is ignored)

python -c 'import yaml; d = "test_dict:\n notify: one\n notify: two"; y = yaml.load(d); print y'
{'test_dict': {'notify': 'two'}}

I'm not convinced the logic is any easier - I'd just notify a full restart when something fundamental changed, and a reload otherwise.


Reply to this email directly or view it on GitHub.

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

No branches or pull requests

3 participants