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

Commit637e86e

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 parent73cda80 commit637e86e

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")));
@@ -236,7 +241,9 @@ pg_control_recovery(PG_FUNCTION_ARGS)
236241
tupdesc=BlessTupleDesc(tupdesc);
237242

238243
/* read the control file */
244+
LWLockAcquire(ControlFileLock,LW_SHARED);
239245
ControlFile=get_controlfile(DataDir,&crc_ok);
246+
LWLockRelease(ControlFileLock);
240247
if (!crc_ok)
241248
ereport(ERROR,
242249
(errmsg("calculated CRC checksum does not match value stored in file")));
@@ -303,7 +310,9 @@ pg_control_init(PG_FUNCTION_ARGS)
303310
tupdesc=BlessTupleDesc(tupdesc);
304311

305312
/* read the control file */
313+
LWLockAcquire(ControlFileLock,LW_SHARED);
306314
ControlFile=get_controlfile(DataDir,&crc_ok);
315+
LWLockRelease(ControlFileLock);
307316
if (!crc_ok)
308317
ereport(ERROR,
309318
(errmsg("calculated CRC checksum does not match value stored in file")));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp