@@ -917,8 +917,7 @@ static void AdvanceXLInsertBuffer(XLogRecPtr upto, bool opportunistic);
917
917
static bool XLogCheckpointNeeded (XLogSegNo new_segno );
918
918
static void XLogWrite (XLogwrtRqst WriteRqst , bool flexible );
919
919
static bool InstallXLogFileSegment (XLogSegNo * segno , char * tmppath ,
920
- bool find_free , XLogSegNo max_segno ,
921
- bool use_lock );
920
+ bool find_free , XLogSegNo max_segno );
922
921
static int XLogFileRead (XLogSegNo segno , int emode , TimeLineID tli ,
923
922
XLogSource source , bool notfoundOk );
924
923
static int XLogFileReadAnyTLI (XLogSegNo segno , int emode , XLogSource source );
@@ -2509,7 +2508,7 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible)
2509
2508
2510
2509
/* create/use new log file */
2511
2510
use_existent = true;
2512
- openLogFile = XLogFileInit (openLogSegNo , & use_existent , true );
2511
+ openLogFile = XLogFileInit (openLogSegNo , & use_existent );
2513
2512
ReserveExternalFD ();
2514
2513
}
2515
2514
@@ -3263,10 +3262,6 @@ XLogNeedsFlush(XLogRecPtr record)
3263
3262
* pre-existing file will be deleted). On return, true if a pre-existing
3264
3263
* file was used.
3265
3264
*
3266
- * use_lock: if true, acquire ControlFileLock while moving file into
3267
- * place. This should be true except during bootstrap log creation. The
3268
- * caller must *not* hold the lock at call.
3269
- *
3270
3265
* Returns FD of opened file.
3271
3266
*
3272
3267
* Note: errors here are ERROR not PANIC because we might or might not be
@@ -3275,7 +3270,7 @@ XLogNeedsFlush(XLogRecPtr record)
3275
3270
* in a critical section.
3276
3271
*/
3277
3272
int
3278
- XLogFileInit (XLogSegNo logsegno , bool * use_existent , bool use_lock )
3273
+ XLogFileInit (XLogSegNo logsegno , bool * use_existent )
3279
3274
{
3280
3275
char path [MAXPGPATH ];
3281
3276
char tmppath [MAXPGPATH ];
@@ -3420,8 +3415,7 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent, bool use_lock)
3420
3415
*/
3421
3416
max_segno = logsegno + CheckPointSegments ;
3422
3417
if (!InstallXLogFileSegment (& installed_segno , tmppath ,
3423
- * use_existent , max_segno ,
3424
- use_lock ))
3418
+ * use_existent , max_segno ))
3425
3419
{
3426
3420
/*
3427
3421
* No need for any more future segments, or InstallXLogFileSegment()
@@ -3578,7 +3572,7 @@ XLogFileCopy(XLogSegNo destsegno, TimeLineID srcTLI, XLogSegNo srcsegno,
3578
3572
/*
3579
3573
* Now move the segment into place with its final name.
3580
3574
*/
3581
- if (!InstallXLogFileSegment (& destsegno , tmppath , false, 0 , false ))
3575
+ if (!InstallXLogFileSegment (& destsegno , tmppath , false, 0 ))
3582
3576
elog (ERROR , "InstallXLogFileSegment should not have failed" );
3583
3577
}
3584
3578
@@ -3602,29 +3596,20 @@ XLogFileCopy(XLogSegNo destsegno, TimeLineID srcTLI, XLogSegNo srcsegno,
3602
3596
* free slot is found between *segno and max_segno. (Ignored when find_free
3603
3597
* is false.)
3604
3598
*
3605
- * use_lock: if true, acquire ControlFileLock while moving file into
3606
- * place. This should be true except during bootstrap log creation. The
3607
- * caller must *not* hold the lock at call.
3608
- *
3609
3599
* Returns true if the file was installed successfully. false indicates that
3610
3600
* max_segno limit was exceeded, or an error occurred while renaming the
3611
3601
* file into place.
3612
3602
*/
3613
3603
static bool
3614
3604
InstallXLogFileSegment (XLogSegNo * segno , char * tmppath ,
3615
- bool find_free , XLogSegNo max_segno ,
3616
- bool use_lock )
3605
+ bool find_free , XLogSegNo max_segno )
3617
3606
{
3618
3607
char path [MAXPGPATH ];
3619
3608
struct stat stat_buf ;
3620
3609
3621
3610
XLogFilePath (path , ThisTimeLineID , * segno , wal_segment_size );
3622
3611
3623
- /*
3624
- * We want to be sure that only one process does this at a time.
3625
- */
3626
- if (use_lock )
3627
- LWLockAcquire (ControlFileLock , LW_EXCLUSIVE );
3612
+ LWLockAcquire (ControlFileLock , LW_EXCLUSIVE );
3628
3613
3629
3614
if (!find_free )
3630
3615
{
@@ -3639,8 +3624,7 @@ InstallXLogFileSegment(XLogSegNo *segno, char *tmppath,
3639
3624
if ((* segno ) >= max_segno )
3640
3625
{
3641
3626
/* Failed to find a free slot within specified range */
3642
- if (use_lock )
3643
- LWLockRelease (ControlFileLock );
3627
+ LWLockRelease (ControlFileLock );
3644
3628
return false;
3645
3629
}
3646
3630
(* segno )++ ;
@@ -3651,14 +3635,12 @@ InstallXLogFileSegment(XLogSegNo *segno, char *tmppath,
3651
3635
Assert (access (path , F_OK ) != 0 && errno == ENOENT );
3652
3636
if (durable_rename (tmppath , path , LOG ) != 0 )
3653
3637
{
3654
- if (use_lock )
3655
- LWLockRelease (ControlFileLock );
3638
+ LWLockRelease (ControlFileLock );
3656
3639
/* durable_rename already emitted log message */
3657
3640
return false;
3658
3641
}
3659
3642
3660
- if (use_lock )
3661
- LWLockRelease (ControlFileLock );
3643
+ LWLockRelease (ControlFileLock );
3662
3644
3663
3645
return true;
3664
3646
}
@@ -3929,7 +3911,7 @@ PreallocXlogFiles(XLogRecPtr endptr)
3929
3911
{
3930
3912
_logSegNo ++ ;
3931
3913
use_existent = true;
3932
- lf = XLogFileInit (_logSegNo , & use_existent , true );
3914
+ lf = XLogFileInit (_logSegNo , & use_existent );
3933
3915
close (lf );
3934
3916
if (!use_existent )
3935
3917
CheckpointStats .ckpt_segs_added ++ ;
@@ -4206,7 +4188,7 @@ RemoveXlogFile(const char *segname, XLogRecPtr lastredoptr, XLogRecPtr endptr)
4206
4188
endlogSegNo <= recycleSegNo &&
4207
4189
lstat (path , & statbuf ) == 0 && S_ISREG (statbuf .st_mode ) &&
4208
4190
InstallXLogFileSegment (& endlogSegNo , path ,
4209
- true, recycleSegNo , true ))
4191
+ true, recycleSegNo ))
4210
4192
{
4211
4193
ereport (DEBUG2 ,
4212
4194
(errmsg ("recycled write-ahead log file \"%s\"" ,
@@ -5342,7 +5324,7 @@ BootStrapXLOG(void)
5342
5324
5343
5325
/* Create first XLOG segment file */
5344
5326
use_existent = false;
5345
- openLogFile = XLogFileInit (1 , & use_existent , false );
5327
+ openLogFile = XLogFileInit (1 , & use_existent );
5346
5328
5347
5329
/*
5348
5330
* We needn't bother with Reserve/ReleaseExternalFD here, since we'll
@@ -5651,7 +5633,7 @@ exitArchiveRecovery(TimeLineID endTLI, XLogRecPtr endOfLog)
5651
5633
bool use_existent = true;
5652
5634
int fd ;
5653
5635
5654
- fd = XLogFileInit (startLogSegNo , & use_existent , true );
5636
+ fd = XLogFileInit (startLogSegNo , & use_existent );
5655
5637
5656
5638
if (close (fd ) != 0 )
5657
5639
{
0 commit comments