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

Adding a Postgres plugin restarts Postgres #61480

Closed
jamessewell opened this issue May 14, 2019 · 3 comments
Closed

Adding a Postgres plugin restarts Postgres #61480

jamessewell opened this issue May 14, 2019 · 3 comments

Comments

@jamessewell
Copy link

Issue description

Using the new Postgresql design when extensions are added to Postgresql using extraPlugins a new postgresql-and-plugins derivation is created.

While this solves a lot of other issues, one it creates is that adding extensions causes the Postgresql service to be restarted (which isn't strictly needed).

Steps to reproduce

Start a postgresql service, add

extraPlugins = [ pg_hll ] 

to the config and switch to it - a new postgresql-and-plugins derivation will be created and activated, which will cause a service stop / start.

Technical details

  • system: "x86_64-linux"
  • host os: Linux 4.19.37, NixOS, 19.09pre179307.bc94dcf5002 (Loris)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.2.2
  • channels(jirotech): ""
  • channels(root): "nixos-19.09pre179307.bc94dcf5002"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos
@jbboehr
Copy link
Contributor

jbboehr commented May 14, 2019

You can probably disable this behavior for your own use case by setting systemd.services.postgresql.restartIfChanged = false. I believe this will apply to any change that would normally restart the service, however.

Example current usage:

restartIfChanged = false; # do not restart on "nixos-rebuild switch". It would seal the storage and disrupt the clients.

@danbst
Copy link
Contributor

danbst commented Jul 23, 2019

@jamessewell unfortunately, this would be left as by-design for now.

There are a few problems, some PG related, some Nix related.

  • not every plugin can be added without restart (shared_preload_libraries). We want to distinguish "requires restart" event during normal activation, but NixOS doesn't handle this very good now. For example, I don't want PG restarts, but if I have to, I want to be notified. NixOS doesn't notify about this currently
  • the design of Nix and NixOS is to be purely functional/atomic, but reloadable PG can only be implemented with some kind of state. Currently, the only place in NixOS which manages state correctly, is environment.etc, or /etc/static directory. So the implementation should put plugins there and then wrap PG with NIX_PGLIBDIR=/etc/static/pg-plugins/.... :/

So stick to restarts for now. I've created meta-issue #65296 to track this

@danbst danbst closed this as completed Jul 23, 2019
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

4 participants
@jbboehr @danbst @jamessewell and others