feat(compute01): Upgrade postgres to 16.2
All checks were successful
build configuration / build_vault01 (push) Successful in 1m15s
build configuration / build_rescue01 (push) Successful in 1m15s
build configuration / build_storage01 (push) Successful in 1m18s
build configuration / build_web02 (push) Successful in 1m24s
lint / check (push) Successful in 25s
build configuration / build_web01 (push) Successful in 1m51s
build configuration / build_compute01 (push) Successful in 1m58s
build configuration / push_to_cache (push) Successful in 2m14s

This commit is contained in:
Tom Hubrecht 2024-05-01 16:01:44 +02:00
parent 17a6e085b5
commit 0eb813c8bf
2 changed files with 30 additions and 23 deletions

View file

@ -4,7 +4,7 @@
services.postgresql = { services.postgresql = {
enable = true; enable = true;
package = pkgs.postgresql_14; package = pkgs.postgresql_16;
settings = { settings = {
checkpoint_completion_target = 0.90625; checkpoint_completion_target = 0.90625;
@ -25,4 +25,10 @@
work_mem = "83886kB"; work_mem = "83886kB";
}; };
}; };
dgn-console = {
# Update the versions below for upgrading
pg-upgrade-to = pkgs.postgresql_16.withPackages (ps: [ ps.postgis ]);
pg-upgrade-from = pkgs.postgresql_16.withPackages (ps: [ ps.postgis ]);
};
} }

View file

@ -16,6 +16,11 @@ in
default = true; default = true;
}; };
pg-upgrade-from = mkOption {
type = lib.types.package;
default = config.services.postgresql.package;
};
pg-upgrade-to = mkOption { pg-upgrade-to = mkOption {
type = lib.types.package; type = lib.types.package;
default = pkgs.postgresql_15; default = pkgs.postgresql_15;
@ -77,21 +82,17 @@ in
tcpdump tcpdump
]) ])
++ [ config.boot.kernelPackages.perf ] ++ [ config.boot.kernelPackages.perf ]
++ ++ lib.optional (config.services.postgresql.enable && cfg.pg-upgrade-from != cfg.pg-upgrade-to) (
lib.optional
(config.services.postgresql.enable && config.services.postgresql.package != cfg.pg-upgrade-to)
(
pkgs.writeScriptBin "upgrade-pg-cluster" '' pkgs.writeScriptBin "upgrade-pg-cluster" ''
set -eux set -eux
# XXX it's perhaps advisable to stop all services that depend on postgresql # XXX it's perhaps advisable to stop all services that depend on postgresql
systemctl stop postgresql systemctl stop postgresql
export NEWDATA="/var/lib/postgresql/${cfg.pg-upgrade-to.psqlSchema}" export NEWDATA="/var/lib/postgresql/${cfg.pg-upgrade-to.psqlSchema}"
export NEWBIN="${cfg.pg-upgrade-to}/bin" export NEWBIN="${cfg.pg-upgrade-to}/bin"
export OLDDATA="${config.services.postgresql.dataDir}" export OLDDATA="${config.services.postgresql.dataDir}"
export OLDBIN="${config.services.postgresql.package}/bin" export OLDBIN="${cfg.pg-upgrade-from}/bin"
install -d -m 0700 -o postgres -g postgres "$NEWDATA" install -d -m 0700 -o postgres -g postgres "$NEWDATA"
cd "$NEWDATA" cd "$NEWDATA"