@@ -913,8 +913,7 @@ static void AdvanceXLInsertBuffer(XLogRecPtr upto, bool opportunistic);
913913static bool XLogCheckpointNeeded (XLogSegNo new_segno );
914914static void XLogWrite (XLogwrtRqst WriteRqst , bool flexible );
915915static bool InstallXLogFileSegment (XLogSegNo * segno , char * tmppath ,
916- bool find_free , XLogSegNo max_segno ,
917- bool use_lock );
916+ bool find_free , XLogSegNo max_segno );
918917static int XLogFileRead (XLogSegNo segno , int emode , TimeLineID tli ,
919918 XLogSource source , bool notfoundOk );
920919static int XLogFileReadAnyTLI (XLogSegNo segno , int emode , XLogSource source );
@@ -2492,7 +2491,7 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible)
24922491
24932492 /* create/use new log file */
24942493 use_existent = true;
2495- openLogFile = XLogFileInit (openLogSegNo , & use_existent , true );
2494+ openLogFile = XLogFileInit (openLogSegNo , & use_existent );
24962495 ReserveExternalFD ();
24972496 }
24982497
@@ -3265,10 +3264,6 @@ XLogNeedsFlush(XLogRecPtr record)
32653264 * pre-existing file will be deleted). On return, true if a pre-existing
32663265 * file was used.
32673266 *
3268- * use_lock: if true, acquire ControlFileLock while moving file into
3269- * place. This should be true except during bootstrap log creation. The
3270- * caller must *not* hold the lock at call.
3271- *
32723267 * Returns FD of opened file.
32733268 *
32743269 * Note: errors here are ERROR not PANIC because we might or might not be
@@ -3277,7 +3272,7 @@ XLogNeedsFlush(XLogRecPtr record)
32773272 * in a critical section.
32783273 */
32793274int
3280- XLogFileInit (XLogSegNo logsegno , bool * use_existent , bool use_lock )
3275+ XLogFileInit (XLogSegNo logsegno , bool * use_existent )
32813276{
32823277 char path [MAXPGPATH ];
32833278 char tmppath [MAXPGPATH ];
@@ -3437,8 +3432,7 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent, bool use_lock)
34373432 */
34383433 max_segno = logsegno + CheckPointSegments ;
34393434 if (!InstallXLogFileSegment (& installed_segno , tmppath ,
3440- * use_existent , max_segno ,
3441- use_lock ))
3435+ * use_existent , max_segno ))
34423436 {
34433437 /*
34443438 * No need for any more future segments, or InstallXLogFileSegment()
@@ -3592,7 +3586,7 @@ XLogFileCopy(XLogSegNo destsegno, TimeLineID srcTLI, XLogSegNo srcsegno,
35923586 /*
35933587 * Now move the segment into place with its final name.
35943588 */
3595- if (!InstallXLogFileSegment (& destsegno , tmppath , false, 0 , false ))
3589+ if (!InstallXLogFileSegment (& destsegno , tmppath , false, 0 ))
35963590 elog (ERROR , "InstallXLogFileSegment should not have failed" );
35973591}
35983592
@@ -3616,29 +3610,20 @@ XLogFileCopy(XLogSegNo destsegno, TimeLineID srcTLI, XLogSegNo srcsegno,
36163610 * free slot is found between *segno and max_segno. (Ignored when find_free
36173611 * is false.)
36183612 *
3619- * use_lock: if true, acquire ControlFileLock while moving file into
3620- * place. This should be true except during bootstrap log creation. The
3621- * caller must *not* hold the lock at call.
3622- *
36233613 * Returns true if the file was installed successfully. false indicates that
36243614 * max_segno limit was exceeded, or an error occurred while renaming the
36253615 * file into place.
36263616 */
36273617static bool
36283618InstallXLogFileSegment (XLogSegNo * segno , char * tmppath ,
3629- bool find_free , XLogSegNo max_segno ,
3630- bool use_lock )
3619+ bool find_free , XLogSegNo max_segno )
36313620{
36323621 char path [MAXPGPATH ];
36333622 struct stat stat_buf ;
36343623
36353624 XLogFilePath (path , ThisTimeLineID , * segno , wal_segment_size );
36363625
3637- /*
3638- * We want to be sure that only one process does this at a time.
3639- */
3640- if (use_lock )
3641- LWLockAcquire (ControlFileLock , LW_EXCLUSIVE );
3626+ LWLockAcquire (ControlFileLock , LW_EXCLUSIVE );
36423627
36433628 if (!find_free )
36443629 {
@@ -3653,8 +3638,7 @@ InstallXLogFileSegment(XLogSegNo *segno, char *tmppath,
36533638 if ((* segno ) >= max_segno )
36543639 {
36553640 /* Failed to find a free slot within specified range */
3656- if (use_lock )
3657- LWLockRelease (ControlFileLock );
3641+ LWLockRelease (ControlFileLock );
36583642 return false;
36593643 }
36603644 (* segno )++ ;
@@ -3668,14 +3652,12 @@ InstallXLogFileSegment(XLogSegNo *segno, char *tmppath,
36683652 */
36693653 if (durable_rename_excl (tmppath , path , LOG ) != 0 )
36703654 {
3671- if (use_lock )
3672- LWLockRelease (ControlFileLock );
3655+ LWLockRelease (ControlFileLock );
36733656 /* durable_rename_excl already emitted log message */
36743657 return false;
36753658 }
36763659
3677- if (use_lock )
3678- LWLockRelease (ControlFileLock );
3660+ LWLockRelease (ControlFileLock );
36793661
36803662 return true;
36813663}
@@ -3946,7 +3928,7 @@ PreallocXlogFiles(XLogRecPtr endptr)
39463928 {
39473929 _logSegNo ++ ;
39483930 use_existent = true;
3949- lf = XLogFileInit (_logSegNo , & use_existent , true );
3931+ lf = XLogFileInit (_logSegNo , & use_existent );
39503932 close (lf );
39513933 if (!use_existent )
39523934 CheckpointStats .ckpt_segs_added ++ ;
@@ -4223,7 +4205,7 @@ RemoveXlogFile(const char *segname, XLogSegNo recycleSegNo,
42234205 * endlogSegNo <= recycleSegNo &&
42244206 lstat (path , & statbuf ) == 0 && S_ISREG (statbuf .st_mode ) &&
42254207 InstallXLogFileSegment (endlogSegNo , path ,
4226- true, recycleSegNo , true ))
4208+ true, recycleSegNo ))
42274209 {
42284210 ereport (DEBUG2 ,
42294211 (errmsg_internal ("recycled write-ahead log file \"%s\"" ,
@@ -5341,7 +5323,7 @@ BootStrapXLOG(void)
53415323
53425324 /* Create first XLOG segment file */
53435325 use_existent = false;
5344- openLogFile = XLogFileInit (1 , & use_existent , false );
5326+ openLogFile = XLogFileInit (1 , & use_existent );
53455327
53465328 /*
53475329 * We needn't bother with Reserve/ReleaseExternalFD here, since we'll
@@ -5650,7 +5632,7 @@ exitArchiveRecovery(TimeLineID endTLI, XLogRecPtr endOfLog)
56505632 bool use_existent = true;
56515633 int fd ;
56525634
5653- fd = XLogFileInit (startLogSegNo , & use_existent , true );
5635+ fd = XLogFileInit (startLogSegNo , & use_existent );
56545636
56555637 if (close (fd ) != 0 )
56565638 {
0 commit comments