Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfd11b84

Browse files
committed
Fix locking bugs that could corrupt pg_control.
The redo routines for XLOG_CHECKPOINT_{ONLINE,SHUTDOWN} must acquireControlFileLock before modifying ControlFile->checkPointCopy, or thecheckpointer could write out a control file with a bad checksum.Likewise, XLogReportParameters() must acquire ControlFileLock beforemodifying ControlFile and calling UpdateControlFile().Back-patch to all supported releases.Author: Nathan Bossart <bossartn@amazon.com>Author: Fujii Masao <masao.fujii@oss.nttdata.com>Reviewed-by: Fujii Masao <masao.fujii@oss.nttdata.com>Reviewed-by: Michael Paquier <michael@paquier.xyz>Reviewed-by: Thomas Munro <thomas.munro@gmail.com>Discussion:https://postgr.es/m/70BF24D6-DC51-443F-B55A-95735803842A%40amazon.com
1 parent682c28b commitfd11b84

File tree

1 file changed

+8
-0
lines changed
  • src/backend/access/transam

1 file changed

+8
-0
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9647,6 +9647,8 @@ XLogReportParameters(void)
96479647
XLogFlush(recptr);
96489648
}
96499649

9650+
LWLockAcquire(ControlFileLock,LW_EXCLUSIVE);
9651+
96509652
ControlFile->MaxConnections=MaxConnections;
96519653
ControlFile->max_worker_processes=max_worker_processes;
96529654
ControlFile->max_prepared_xacts=max_prepared_xacts;
@@ -9655,6 +9657,8 @@ XLogReportParameters(void)
96559657
ControlFile->wal_log_hints=wal_log_hints;
96569658
ControlFile->track_commit_timestamp=track_commit_timestamp;
96579659
UpdateControlFile();
9660+
9661+
LWLockRelease(ControlFileLock);
96589662
}
96599663
}
96609664

@@ -9879,8 +9883,10 @@ xlog_redo(XLogReaderState *record)
98799883
}
98809884

98819885
/* ControlFile->checkPointCopy always tracks the latest ckpt XID */
9886+
LWLockAcquire(ControlFileLock,LW_EXCLUSIVE);
98829887
ControlFile->checkPointCopy.nextXidEpoch=checkPoint.nextXidEpoch;
98839888
ControlFile->checkPointCopy.nextXid=checkPoint.nextXid;
9889+
LWLockRelease(ControlFileLock);
98849890

98859891
/* Update shared-memory copy of checkpoint XID/epoch */
98869892
SpinLockAcquire(&XLogCtl->info_lck);
@@ -9938,8 +9944,10 @@ xlog_redo(XLogReaderState *record)
99389944
SetTransactionIdLimit(checkPoint.oldestXid,
99399945
checkPoint.oldestXidDB);
99409946
/* ControlFile->checkPointCopy always tracks the latest ckpt XID */
9947+
LWLockAcquire(ControlFileLock,LW_EXCLUSIVE);
99419948
ControlFile->checkPointCopy.nextXidEpoch=checkPoint.nextXidEpoch;
99429949
ControlFile->checkPointCopy.nextXid=checkPoint.nextXid;
9950+
LWLockRelease(ControlFileLock);
99439951

99449952
/* Update shared-memory copy of checkpoint XID/epoch */
99459953
SpinLockAcquire(&XLogCtl->info_lck);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp