@@ -913,8 +913,7 @@ static void AdvanceXLInsertBuffer(XLogRecPtr upto, bool opportunistic);
913
913
static bool XLogCheckpointNeeded (XLogSegNo new_segno );
914
914
static void XLogWrite (XLogwrtRqst WriteRqst , bool flexible );
915
915
static bool InstallXLogFileSegment (XLogSegNo * segno , char * tmppath ,
916
- bool find_free , XLogSegNo max_segno ,
917
- bool use_lock );
916
+ bool find_free , XLogSegNo max_segno );
918
917
static int XLogFileRead (XLogSegNo segno , int emode , TimeLineID tli ,
919
918
XLogSource source , bool notfoundOk );
920
919
static int XLogFileReadAnyTLI (XLogSegNo segno , int emode , XLogSource source );
@@ -2492,7 +2491,7 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible)
2492
2491
2493
2492
/* create/use new log file */
2494
2493
use_existent = true;
2495
- openLogFile = XLogFileInit (openLogSegNo , & use_existent , true );
2494
+ openLogFile = XLogFileInit (openLogSegNo , & use_existent );
2496
2495
ReserveExternalFD ();
2497
2496
}
2498
2497
@@ -3265,10 +3264,6 @@ XLogNeedsFlush(XLogRecPtr record)
3265
3264
* pre-existing file will be deleted). On return, true if a pre-existing
3266
3265
* file was used.
3267
3266
*
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
- *
3272
3267
* Returns FD of opened file.
3273
3268
*
3274
3269
* Note: errors here are ERROR not PANIC because we might or might not be
@@ -3277,7 +3272,7 @@ XLogNeedsFlush(XLogRecPtr record)
3277
3272
* in a critical section.
3278
3273
*/
3279
3274
int
3280
- XLogFileInit (XLogSegNo logsegno , bool * use_existent , bool use_lock )
3275
+ XLogFileInit (XLogSegNo logsegno , bool * use_existent )
3281
3276
{
3282
3277
char path [MAXPGPATH ];
3283
3278
char tmppath [MAXPGPATH ];
@@ -3437,8 +3432,7 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent, bool use_lock)
3437
3432
*/
3438
3433
max_segno = logsegno + CheckPointSegments ;
3439
3434
if (!InstallXLogFileSegment (& installed_segno , tmppath ,
3440
- * use_existent , max_segno ,
3441
- use_lock ))
3435
+ * use_existent , max_segno ))
3442
3436
{
3443
3437
/*
3444
3438
* No need for any more future segments, or InstallXLogFileSegment()
@@ -3592,7 +3586,7 @@ XLogFileCopy(XLogSegNo destsegno, TimeLineID srcTLI, XLogSegNo srcsegno,
3592
3586
/*
3593
3587
* Now move the segment into place with its final name.
3594
3588
*/
3595
- if (!InstallXLogFileSegment (& destsegno , tmppath , false, 0 , false ))
3589
+ if (!InstallXLogFileSegment (& destsegno , tmppath , false, 0 ))
3596
3590
elog (ERROR , "InstallXLogFileSegment should not have failed" );
3597
3591
}
3598
3592
@@ -3616,29 +3610,20 @@ XLogFileCopy(XLogSegNo destsegno, TimeLineID srcTLI, XLogSegNo srcsegno,
3616
3610
* free slot is found between *segno and max_segno. (Ignored when find_free
3617
3611
* is false.)
3618
3612
*
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
- *
3623
3613
* Returns true if the file was installed successfully. false indicates that
3624
3614
* max_segno limit was exceeded, or an error occurred while renaming the
3625
3615
* file into place.
3626
3616
*/
3627
3617
static bool
3628
3618
InstallXLogFileSegment (XLogSegNo * segno , char * tmppath ,
3629
- bool find_free , XLogSegNo max_segno ,
3630
- bool use_lock )
3619
+ bool find_free , XLogSegNo max_segno )
3631
3620
{
3632
3621
char path [MAXPGPATH ];
3633
3622
struct stat stat_buf ;
3634
3623
3635
3624
XLogFilePath (path , ThisTimeLineID , * segno , wal_segment_size );
3636
3625
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 );
3642
3627
3643
3628
if (!find_free )
3644
3629
{
@@ -3653,8 +3638,7 @@ InstallXLogFileSegment(XLogSegNo *segno, char *tmppath,
3653
3638
if ((* segno ) >= max_segno )
3654
3639
{
3655
3640
/* Failed to find a free slot within specified range */
3656
- if (use_lock )
3657
- LWLockRelease (ControlFileLock );
3641
+ LWLockRelease (ControlFileLock );
3658
3642
return false;
3659
3643
}
3660
3644
(* segno )++ ;
@@ -3668,14 +3652,12 @@ InstallXLogFileSegment(XLogSegNo *segno, char *tmppath,
3668
3652
*/
3669
3653
if (durable_rename_excl (tmppath , path , LOG ) != 0 )
3670
3654
{
3671
- if (use_lock )
3672
- LWLockRelease (ControlFileLock );
3655
+ LWLockRelease (ControlFileLock );
3673
3656
/* durable_rename_excl already emitted log message */
3674
3657
return false;
3675
3658
}
3676
3659
3677
- if (use_lock )
3678
- LWLockRelease (ControlFileLock );
3660
+ LWLockRelease (ControlFileLock );
3679
3661
3680
3662
return true;
3681
3663
}
@@ -3946,7 +3928,7 @@ PreallocXlogFiles(XLogRecPtr endptr)
3946
3928
{
3947
3929
_logSegNo ++ ;
3948
3930
use_existent = true;
3949
- lf = XLogFileInit (_logSegNo , & use_existent , true );
3931
+ lf = XLogFileInit (_logSegNo , & use_existent );
3950
3932
close (lf );
3951
3933
if (!use_existent )
3952
3934
CheckpointStats .ckpt_segs_added ++ ;
@@ -4223,7 +4205,7 @@ RemoveXlogFile(const char *segname, XLogSegNo recycleSegNo,
4223
4205
* endlogSegNo <= recycleSegNo &&
4224
4206
lstat (path , & statbuf ) == 0 && S_ISREG (statbuf .st_mode ) &&
4225
4207
InstallXLogFileSegment (endlogSegNo , path ,
4226
- true, recycleSegNo , true ))
4208
+ true, recycleSegNo ))
4227
4209
{
4228
4210
ereport (DEBUG2 ,
4229
4211
(errmsg_internal ("recycled write-ahead log file \"%s\"" ,
@@ -5341,7 +5323,7 @@ BootStrapXLOG(void)
5341
5323
5342
5324
/* Create first XLOG segment file */
5343
5325
use_existent = false;
5344
- openLogFile = XLogFileInit (1 , & use_existent , false );
5326
+ openLogFile = XLogFileInit (1 , & use_existent );
5345
5327
5346
5328
/*
5347
5329
* We needn't bother with Reserve/ReleaseExternalFD here, since we'll
@@ -5650,7 +5632,7 @@ exitArchiveRecovery(TimeLineID endTLI, XLogRecPtr endOfLog)
5650
5632
bool use_existent = true;
5651
5633
int fd ;
5652
5634
5653
- fd = XLogFileInit (startLogSegNo , & use_existent , true );
5635
+ fd = XLogFileInit (startLogSegNo , & use_existent );
5654
5636
5655
5637
if (close (fd ) != 0 )
5656
5638
{
0 commit comments