Fix locking bugs that could corrupt pg_control.
authorThomas Munro
Mon, 8 Jun 2020 01:57:24 +0000 (13:57 +1200)
committerThomas Munro
Mon, 8 Jun 2020 01:59:57 +0000 (13:59 +1200)
commit48eb6a3c895dac239f7e04fc3d62c09a17c1fc4a
treeb65a746af5e931c04970e87c158b18115d944464
parenta35896c4b2a18b84f35c2cc6a9f5aee6ba041c43
Fix locking bugs that could corrupt pg_control.

The redo routines for XLOG_CHECKPOINT_{ONLINE,SHUTDOWN} must acquire
ControlFileLock before modifying ControlFile->checkPointCopy, or the
checkpointer could write out a control file with a bad checksum.

Likewise, XLogReportParameters() must acquire ControlFileLock before
modifying ControlFile and calling UpdateControlFile().

Back-patch to all supported releases.

Author: Nathan Bossart 
Author: Fujii Masao 
Reviewed-by: Fujii Masao
Reviewed-by: Michael Paquier
Reviewed-by: Thomas Munro
Discussion: https://postgr.es/m/70BF24D6-DC51-443F-B55A-95735803842A%40amazon.com
src/backend/access/transam/xlog.c