24
24
#include "common/controldata_utils.h"
25
25
#include "funcapi.h"
26
26
#include "miscadmin.h"
27
+ #include "storage/lwlock.h"
27
28
#include "utils/builtins.h"
28
29
#include "utils/pg_lsn.h"
29
30
#include "utils/timestamp.h"
@@ -42,7 +43,9 @@ pg_control_system(PG_FUNCTION_ARGS)
42
43
elog (ERROR , "return type must be a row type" );
43
44
44
45
/* read the control file */
46
+ LWLockAcquire (ControlFileLock , LW_SHARED );
45
47
ControlFile = get_controlfile (DataDir , & crc_ok );
48
+ LWLockRelease (ControlFileLock );
46
49
if (!crc_ok )
47
50
ereport (ERROR ,
48
51
(errmsg ("calculated CRC checksum does not match value stored in file" )));
@@ -80,7 +83,9 @@ pg_control_checkpoint(PG_FUNCTION_ARGS)
80
83
elog (ERROR , "return type must be a row type" );
81
84
82
85
/* Read the control file. */
86
+ LWLockAcquire (ControlFileLock , LW_SHARED );
83
87
ControlFile = get_controlfile (DataDir , & crc_ok );
88
+ LWLockRelease (ControlFileLock );
84
89
if (!crc_ok )
85
90
ereport (ERROR ,
86
91
(errmsg ("calculated CRC checksum does not match value stored in file" )));
@@ -169,7 +174,9 @@ pg_control_recovery(PG_FUNCTION_ARGS)
169
174
elog (ERROR , "return type must be a row type" );
170
175
171
176
/* read the control file */
177
+ LWLockAcquire (ControlFileLock , LW_SHARED );
172
178
ControlFile = get_controlfile (DataDir , & crc_ok );
179
+ LWLockRelease (ControlFileLock );
173
180
if (!crc_ok )
174
181
ereport (ERROR ,
175
182
(errmsg ("calculated CRC checksum does not match value stored in file" )));
@@ -208,7 +215,9 @@ pg_control_init(PG_FUNCTION_ARGS)
208
215
elog (ERROR , "return type must be a row type" );
209
216
210
217
/* read the control file */
218
+ LWLockAcquire (ControlFileLock , LW_SHARED );
211
219
ControlFile = get_controlfile (DataDir , & crc_ok );
220
+ LWLockRelease (ControlFileLock );
212
221
if (!crc_ok )
213
222
ereport (ERROR ,
214
223
(errmsg ("calculated CRC checksum does not match value stored in file" )));
0 commit comments