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

Commitae9da35

Browse files
committed
Acquire ControlFileLock in relevant SQL functions.
Commitdc7d70e added functions that read the control file, but didn'tacquire ControlFileLock. With unlucky timing, file systems that haveweak interlocking like ext4 and ntfs could expose partially overwrittencontents, and the checksum would fail.Back-patch to all supported releases.Reviewed-by: David Steele <david@pgmasters.net>Reviewed-by: Anton A. Melnikov <aamelnikov@inbox.ru>Reviewed-by: Michael Paquier <michael@paquier.xyz>Discussion:https://postgr.es/m/20221123014224.xisi44byq3cf5psi%40awork3.anarazel.de
1 parent6fd1dbd commitae9da35

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

‎src/backend/utils/misc/pg_controldata.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include"common/controldata_utils.h"
2525
#include"funcapi.h"
2626
#include"miscadmin.h"
27+
#include"storage/lwlock.h"
2728
#include"utils/builtins.h"
2829
#include"utils/pg_lsn.h"
2930
#include"utils/timestamp.h"
@@ -54,7 +55,9 @@ pg_control_system(PG_FUNCTION_ARGS)
5455
tupdesc=BlessTupleDesc(tupdesc);
5556

5657
/* read the control file */
58+
LWLockAcquire(ControlFileLock,LW_SHARED);
5759
ControlFile=get_controlfile(DataDir,&crc_ok);
60+
LWLockRelease(ControlFileLock);
5861
if (!crc_ok)
5962
ereport(ERROR,
6063
(errmsg("calculated CRC checksum does not match value stored in file")));
@@ -132,7 +135,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
132135
tupdesc=BlessTupleDesc(tupdesc);
133136

134137
/* Read the control file. */
138+
LWLockAcquire(ControlFileLock,LW_SHARED);
135139
ControlFile=get_controlfile(DataDir,&crc_ok);
140+
LWLockRelease(ControlFileLock);
136141
if (!crc_ok)
137142
ereport(ERROR,
138143
(errmsg("calculated CRC checksum does not match value stored in file")));
@@ -235,7 +240,9 @@ pg_control_recovery(PG_FUNCTION_ARGS)
235240
tupdesc=BlessTupleDesc(tupdesc);
236241

237242
/* read the control file */
243+
LWLockAcquire(ControlFileLock,LW_SHARED);
238244
ControlFile=get_controlfile(DataDir,&crc_ok);
245+
LWLockRelease(ControlFileLock);
239246
if (!crc_ok)
240247
ereport(ERROR,
241248
(errmsg("calculated CRC checksum does not match value stored in file")));
@@ -300,7 +307,9 @@ pg_control_init(PG_FUNCTION_ARGS)
300307
tupdesc=BlessTupleDesc(tupdesc);
301308

302309
/* read the control file */
310+
LWLockAcquire(ControlFileLock,LW_SHARED);
303311
ControlFile=get_controlfile(DataDir,&crc_ok);
312+
LWLockRelease(ControlFileLock);
304313
if (!crc_ok)
305314
ereport(ERROR,
306315
(errmsg("calculated CRC checksum does not match value stored in file")));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp