@@ -927,8 +927,7 @@ static void AdvanceXLInsertBuffer(XLogRecPtr upto, bool opportunistic);
927
927
static bool XLogCheckpointNeeded (XLogSegNo new_segno );
928
928
static void XLogWrite (XLogwrtRqst WriteRqst , bool flexible );
929
929
static bool InstallXLogFileSegment (XLogSegNo * segno , char * tmppath ,
930
- bool find_free , XLogSegNo max_segno ,
931
- bool use_lock );
930
+ bool find_free , XLogSegNo max_segno );
932
931
static int XLogFileRead (XLogSegNo segno , int emode , TimeLineID tli ,
933
932
XLogSource source , bool notfoundOk );
934
933
static int XLogFileReadAnyTLI (XLogSegNo segno , int emode , XLogSource source );
@@ -2520,7 +2519,7 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible)
2520
2519
2521
2520
/* create/use new log file */
2522
2521
use_existent = true;
2523
- openLogFile = XLogFileInit (openLogSegNo , & use_existent , true );
2522
+ openLogFile = XLogFileInit (openLogSegNo , & use_existent );
2524
2523
ReserveExternalFD ();
2525
2524
}
2526
2525
@@ -3293,10 +3292,6 @@ XLogNeedsFlush(XLogRecPtr record)
3293
3292
* pre-existing file will be deleted). On return, true if a pre-existing
3294
3293
* file was used.
3295
3294
*
3296
- * use_lock: if true, acquire ControlFileLock while moving file into
3297
- * place. This should be true except during bootstrap log creation. The
3298
- * caller must *not* hold the lock at call.
3299
- *
3300
3295
* Returns FD of opened file.
3301
3296
*
3302
3297
* Note: errors here are ERROR not PANIC because we might or might not be
@@ -3305,7 +3300,7 @@ XLogNeedsFlush(XLogRecPtr record)
3305
3300
* in a critical section.
3306
3301
*/
3307
3302
int
3308
- XLogFileInit (XLogSegNo logsegno , bool * use_existent , bool use_lock )
3303
+ XLogFileInit (XLogSegNo logsegno , bool * use_existent )
3309
3304
{
3310
3305
char path [MAXPGPATH ];
3311
3306
char tmppath [MAXPGPATH ];
@@ -3465,8 +3460,7 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent, bool use_lock)
3465
3460
*/
3466
3461
max_segno = logsegno + CheckPointSegments ;
3467
3462
if (!InstallXLogFileSegment (& installed_segno , tmppath ,
3468
- * use_existent , max_segno ,
3469
- use_lock ))
3463
+ * use_existent , max_segno ))
3470
3464
{
3471
3465
/*
3472
3466
* No need for any more future segments, or InstallXLogFileSegment()
@@ -3623,7 +3617,7 @@ XLogFileCopy(XLogSegNo destsegno, TimeLineID srcTLI, XLogSegNo srcsegno,
3623
3617
/*
3624
3618
* Now move the segment into place with its final name.
3625
3619
*/
3626
- if (!InstallXLogFileSegment (& destsegno , tmppath , false, 0 , false ))
3620
+ if (!InstallXLogFileSegment (& destsegno , tmppath , false, 0 ))
3627
3621
elog (ERROR , "InstallXLogFileSegment should not have failed" );
3628
3622
}
3629
3623
@@ -3647,29 +3641,20 @@ XLogFileCopy(XLogSegNo destsegno, TimeLineID srcTLI, XLogSegNo srcsegno,
3647
3641
* free slot is found between *segno and max_segno. (Ignored when find_free
3648
3642
* is false.)
3649
3643
*
3650
- * use_lock: if true, acquire ControlFileLock while moving file into
3651
- * place. This should be true except during bootstrap log creation. The
3652
- * caller must *not* hold the lock at call.
3653
- *
3654
3644
* Returns true if the file was installed successfully. false indicates that
3655
3645
* max_segno limit was exceeded, or an error occurred while renaming the
3656
3646
* file into place.
3657
3647
*/
3658
3648
static bool
3659
3649
InstallXLogFileSegment (XLogSegNo * segno , char * tmppath ,
3660
- bool find_free , XLogSegNo max_segno ,
3661
- bool use_lock )
3650
+ bool find_free , XLogSegNo max_segno )
3662
3651
{
3663
3652
char path [MAXPGPATH ];
3664
3653
struct stat stat_buf ;
3665
3654
3666
3655
XLogFilePath (path , ThisTimeLineID , * segno , wal_segment_size );
3667
3656
3668
- /*
3669
- * We want to be sure that only one process does this at a time.
3670
- */
3671
- if (use_lock )
3672
- LWLockAcquire (ControlFileLock , LW_EXCLUSIVE );
3657
+ LWLockAcquire (ControlFileLock , LW_EXCLUSIVE );
3673
3658
3674
3659
if (!find_free )
3675
3660
{
@@ -3684,8 +3669,7 @@ InstallXLogFileSegment(XLogSegNo *segno, char *tmppath,
3684
3669
if ((* segno ) >= max_segno )
3685
3670
{
3686
3671
/* Failed to find a free slot within specified range */
3687
- if (use_lock )
3688
- LWLockRelease (ControlFileLock );
3672
+ LWLockRelease (ControlFileLock );
3689
3673
return false;
3690
3674
}
3691
3675
(* segno )++ ;
@@ -3696,14 +3680,12 @@ InstallXLogFileSegment(XLogSegNo *segno, char *tmppath,
3696
3680
Assert (access (path , F_OK ) != 0 && errno == ENOENT );
3697
3681
if (durable_rename (tmppath , path , LOG ) != 0 )
3698
3682
{
3699
- if (use_lock )
3700
- LWLockRelease (ControlFileLock );
3683
+ LWLockRelease (ControlFileLock );
3701
3684
/* durable_rename already emitted log message */
3702
3685
return false;
3703
3686
}
3704
3687
3705
- if (use_lock )
3706
- LWLockRelease (ControlFileLock );
3688
+ LWLockRelease (ControlFileLock );
3707
3689
3708
3690
return true;
3709
3691
}
@@ -3974,7 +3956,7 @@ PreallocXlogFiles(XLogRecPtr endptr)
3974
3956
{
3975
3957
_logSegNo ++ ;
3976
3958
use_existent = true;
3977
- lf = XLogFileInit (_logSegNo , & use_existent , true );
3959
+ lf = XLogFileInit (_logSegNo , & use_existent );
3978
3960
close (lf );
3979
3961
if (!use_existent )
3980
3962
CheckpointStats .ckpt_segs_added ++ ;
@@ -4251,7 +4233,7 @@ RemoveXlogFile(const char *segname, XLogSegNo recycleSegNo,
4251
4233
* endlogSegNo <= recycleSegNo &&
4252
4234
lstat (path , & statbuf ) == 0 && S_ISREG (statbuf .st_mode ) &&
4253
4235
InstallXLogFileSegment (endlogSegNo , path ,
4254
- true, recycleSegNo , true ))
4236
+ true, recycleSegNo ))
4255
4237
{
4256
4238
ereport (DEBUG2 ,
4257
4239
(errmsg_internal ("recycled write-ahead log file \"%s\"" ,
@@ -5388,7 +5370,7 @@ BootStrapXLOG(void)
5388
5370
5389
5371
/* Create first XLOG segment file */
5390
5372
use_existent = false;
5391
- openLogFile = XLogFileInit (1 , & use_existent , false );
5373
+ openLogFile = XLogFileInit (1 , & use_existent );
5392
5374
5393
5375
/*
5394
5376
* We needn't bother with Reserve/ReleaseExternalFD here, since we'll
@@ -5697,7 +5679,7 @@ exitArchiveRecovery(TimeLineID endTLI, XLogRecPtr endOfLog)
5697
5679
bool use_existent = true;
5698
5680
int fd ;
5699
5681
5700
- fd = XLogFileInit (startLogSegNo , & use_existent , true );
5682
+ fd = XLogFileInit (startLogSegNo , & use_existent );
5701
5683
5702
5684
if (close (fd ) != 0 )
5703
5685
{
0 commit comments