From cd4bd8db0b73b445d061f38a09cf377083666062 Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Sun, 31 May 2020 19:47:36 +0000 Subject: [PATCH 2/3] Acquire ControlFileLock within XLogReportParameters(). XLogReportParameters() must acquire ControlFileLock before modifying ControlFile and calling UpdateControlFile(), or the checkpointer could write out a control file with a bad checksum. Back-patch to all supported releases. Reported-by: Fujii Masao Author: Nathan Bossart Reviewed-by: Fujii Masao, Michael Paquier Discussion: https://postgr.es/m/70BF24D6-DC51-443F-B55A-95735803842A%40amazon.com --- src/backend/access/transam/xlog.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 274b808476..55cac186dc 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -9743,6 +9743,8 @@ XLogReportParameters(void) XLogFlush(recptr); } + LWLockAcquire(ControlFileLock, LW_EXCLUSIVE); + ControlFile->MaxConnections = MaxConnections; ControlFile->max_worker_processes = max_worker_processes; ControlFile->max_wal_senders = max_wal_senders; @@ -9752,6 +9754,8 @@ XLogReportParameters(void) ControlFile->wal_log_hints = wal_log_hints; ControlFile->track_commit_timestamp = track_commit_timestamp; UpdateControlFile(); + + LWLockRelease(ControlFileLock); } } -- 2.16.6