From 5b6ed22a9aa096c88c3113d65ec3c6a0551c4d75 Mon Sep 17 00:00:00 2001 From: Bharath Rupireddy Date: Sat, 29 Aug 2026 03:38:26 +0000 Subject: [PATCH v1] Report an error when the data checksums worker fails to start. Previously, pg_enable_data_checksums() and pg_disable_data_checksums() could return successfully even when the background worker they start to carry out the request never ran. Registering a background worker only reserves a worker slot; the subsequent fork() can still fail. In that case the worker never runs and the checksum state is left unchanged, yet the functions returned as if the request had been accepted. Fix this by waiting for the worker to start up and raising an error if it fails to, so that the caller is not misled into thinking that checksum processing was initiated. Author: Bharath Rupireddy Reviewed-by: Daniel Gustafsson Discussion: https://postgr.es/m/CALj2ACVJk-xnRRtiC_%3DFuLdkWWq-g1y75yZ-pQryzoE3TP9%3DrQ%40mail.gmail.com --- src/backend/postmaster/datachecksum_state.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/backend/postmaster/datachecksum_state.c b/src/backend/postmaster/datachecksum_state.c index f69258bc33d..ec941bb7531 100644 --- a/src/backend/postmaster/datachecksum_state.c +++ b/src/backend/postmaster/datachecksum_state.c @@ -625,6 +625,8 @@ StartDataChecksumsWorkerLauncher(DataChecksumsWorkerOperation op, { BackgroundWorker bgw; BackgroundWorkerHandle *bgw_handle; + BgwHandleStatus status; + pid_t pid; bool running; #ifdef USE_ASSERT_CHECKING @@ -689,6 +691,14 @@ StartDataChecksumsWorkerLauncher(DataChecksumsWorkerOperation op, ereport(ERROR, errcode(ERRCODE_INSUFFICIENT_RESOURCES), errmsg("failed to start background worker to process data checksums")); + + /* Wait for a background worker to start up. */ + status = WaitForBackgroundWorkerStartup(bgw_handle, &pid); + if (status != BGWH_STARTED) + ereport(ERROR, + errcode(ERRCODE_INSUFFICIENT_RESOURCES), + errmsg("could not start background worker to process data checksums"), + errhint("More details may be available in the server log.")); } else { -- 2.47.3