NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.64k stars 13.8k forks source link

Upgrading timescaledb plugin causes issues with ensureDatabases/ensureUsers #214367

Open bouk opened 1 year ago

bouk commented 1 year ago

Describe the bug

If you have ensureDatabases in your postgresql nixos config and you're using timescaledb and timescale has been updated then postgresql will fail to start because it won't be able to ensureDatabases, since it can't find the plugin. This can be fixed with sudo -u postgres psql postgres -c 'ALTER EXTENSION timescaledb UPDATE;', but you need to first remove ensureDatabases from your config because you can't start postgresql otherwise...

Steps To Reproduce

{
  services.postgresql = {
    enable = true;
    package = pkgs.postgresql_14;
    extraPlugins = [ pkgs.postgresql14Packages.timescaledb ];
    settings.shared_preload_libraries = "timescaledb";
    ensureDatabases = [ "exampledb" ];
  };
}

And then deploy again after updating nixpkgs after timescaledb was updated. This gives this error:

LOG:  background worker "TimescaleDB Background Worker Scheduler" (PID 217019) exited...
ERROR:  could not access file "$libdir/timescaledb-2.9.1": No such file or directory

This causes the ExecStartPost of the postgresql service to fail.

Expected behavior

It upgrades cleanly, or at least doesn't cause postgresql.service to fail to start

Notify maintainers

@marsam

apgapg commented 8 months ago

+1

ALTER EXTENSION timescaledb UPDATE; this worked. @bouk thanks a lot