From 6d69b984900a7030ae7557c99ccc56a76297e0de Mon Sep 17 00:00:00 2001 From: Michael Banck Date: Wed, 4 Oct 2023 17:23:11 +0200 Subject: [PATCH] Fix check_archive_ready for version 10 and above The archive_ready check uses the wal_files check with dedicated options - however, since wal_files was fixed for version 10 in 8e6b3c2 it called pg_ls_waldir() even for the archive_ready check which is not appropriate as this only lists files in pg_wal and not in pg_wal/archive_status. This change makes the wal_files check call pg_ls_archive_statusdir() instead if $extrabit (i.e. .ready) is set, fixing issue #150. --- check_postgres.pl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/check_postgres.pl b/check_postgres.pl index c3f1409..1de0bc9 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -9423,8 +9423,17 @@ sub check_wal_files { ## Figure out where the pg_xlog directory is $SQL = qq{SELECT count(*) AS count FROM $lsfunc($lsargs) WHERE $lsfunc ~ E'^[0-9A-F]{24}$extrabit\$'}; ## no critic (RequireInterpolationOfMetachars) - my $SQL10 = $opt{lsfunc} ? $SQL : - qq{SELECT count(*) AS count FROM pg_ls_waldir() WHERE name ~ E'^[0-9A-F]{24}$extrabit\$'}; ## no critic (RequireInterpolationOfMetachars) + my $SQL10 = ""; + + if ($extrabit) { + # check_archive_ready + $SQL10 = $opt{lsfunc} ? $SQL : + qq{SELECT count(*) AS count FROM pg_ls_archive_statusdir() WHERE name ~ E'^[0-9A-F]{24}$extrabit\$'}; ## no critic (RequireInterpolationOfMetachars) + } else { + # check_wal_files + $SQL10 = $opt{lsfunc} ? $SQL : + qq{SELECT count(*) AS count FROM pg_ls_waldir() WHERE name ~ E'^[0-9A-F]{24}\$'}; ## no critic (RequireInterpolationOfMetachars) + } my $info = run_command($SQL, {regex => qr[\d], version => [">9.6 $SQL10"] });