]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Prevent pg_enable/disable_data_checksums() on standby
authorDaniel Gustafsson <dgustafsson@postgresql.org>
Thu, 30 Apr 2026 11:41:41 +0000 (13:41 +0200)
committerDaniel Gustafsson <dgustafsson@postgresql.org>
Thu, 30 Apr 2026 11:41:41 +0000 (13:41 +0200)
These functions missed a RecoveryInProgress() check, allowing them to
be called on a hot standby.  Enabling, or disabling, checksums on the
standby only would cause the cluster to get out of sync and replaying
checksum transitions to fail.

Author: Satyanarayana Narlapuram <satyanarlapuram@gmail.com>
Reviewed-by: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Reviewed-by: Tomas Vondra <tomas@vondra.me>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CAHg+QDfRk4-S7DMmdbXJnQ-xF=sUpMAKuh8b83ObLqYVKx5QLA@mail.gmail.com

src/backend/postmaster/datachecksum_state.c

index 5556a9ca893a5ba2acd503ad7ad15d3ff8fa5717..ea10208614472362b23f78c77249ae74111e83e3 100644 (file)
@@ -487,6 +487,8 @@ AbsorbDataChecksumsBarrier(ProcSignalBarrierType barrier)
 Datum
 disable_data_checksums(PG_FUNCTION_ARGS)
 {
+       PreventCommandDuringRecovery("pg_disable_data_checksums()");
+
        if (!superuser())
                ereport(ERROR,
                                errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
@@ -507,6 +509,8 @@ enable_data_checksums(PG_FUNCTION_ARGS)
        int                     cost_delay = PG_GETARG_INT32(0);
        int                     cost_limit = PG_GETARG_INT32(1);
 
+       PreventCommandDuringRecovery("pg_enable_data_checksums()");
+
        if (!superuser())
                ereport(ERROR,
                                errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),