From 9c59fdb5f7ba7637e4a6188fe1da652a86e396f9 Mon Sep 17 00:00:00 2001 From: Stanislav Grozev Date: Thu, 24 Oct 2024 14:28:05 +0300 Subject: [PATCH] Fix: Background worker not starting on replicas The background worker that's responsible for log rotation doesn't start on the replica nodes, which results in all audit messages going to a single file until the server is restarted. According to the PostgreSQL documentation, ConsistentState and RecoveryFinished are equivalent on the leader, and ConsistentState is enough on the hot replicas, meaning it should work for both node roles. --- logtofile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logtofile.c b/logtofile.c index 08c14bb..95629e3 100644 --- a/logtofile.c +++ b/logtofile.c @@ -96,7 +96,7 @@ void _PG_init(void) /* background worker */ MemSet(&worker, 0, sizeof(BackgroundWorker)); worker.bgw_flags = BGWORKER_SHMEM_ACCESS; - worker.bgw_start_time = BgWorkerStart_RecoveryFinished; + worker.bgw_start_time = BgWorkerStart_ConsistentState; worker.bgw_restart_time = 1; worker.bgw_main_arg = Int32GetDatum(0); worker.bgw_notify_pid = 0;