@ -3299,34 +3299,16 @@ InstallXLogFileSegment(XLogSegNo *segno, char *tmppath,
}
}
/*
/*
* Prefer link ( ) to rename ( ) here just to be really sure that we don ' t
* Perform the rename using link if available , paranoidly trying to avoid
* overwrite an existing logfile . However , there shouldn ' t be one , so
* overwriting an existing file ( there shouldn ' t be one ) .
* rename ( ) is an acceptable substitute except for the truly paranoid .
*/
*/
# if HAVE_WORKING_LINK
if ( durable_link_or_rename ( tmppath , path , LOG ) ! = 0 )
if ( link ( tmppath , path ) < 0 )
{
{
if ( use_lock )
if ( use_lock )
LWLockRelease ( ControlFileLock ) ;
LWLockRelease ( ControlFileLock ) ;
ereport ( LOG ,
/* durable_link_or_rename already emitted log message */
( errcode_for_file_access ( ) ,
errmsg ( " could not link file \" %s \" to \" %s \" (initialization of log file): %m " ,
tmppath , path ) ) ) ;
return false ;
}
unlink ( tmppath ) ;
# else
if ( rename ( tmppath , path ) < 0 )
{
if ( use_lock )
LWLockRelease ( ControlFileLock ) ;
ereport ( LOG ,
( errcode_for_file_access ( ) ,
errmsg ( " could not rename file \" %s \" to \" %s \" (initialization of log file): %m " ,
tmppath , path ) ) ) ;
return false ;
return false ;
}
}
# endif
if ( use_lock )
if ( use_lock )
LWLockRelease ( ControlFileLock ) ;
LWLockRelease ( ControlFileLock ) ;
@ -5339,11 +5321,7 @@ exitArchiveRecovery(TimeLineID endTLI, XLogRecPtr endOfLog)
* re - enter archive recovery mode in a subsequent crash .
* re - enter archive recovery mode in a subsequent crash .
*/
*/
unlink ( RECOVERY_COMMAND_DONE ) ;
unlink ( RECOVERY_COMMAND_DONE ) ;
if ( rename ( RECOVERY_COMMAND_FILE , RECOVERY_COMMAND_DONE ) ! = 0 )
durable_rename ( RECOVERY_COMMAND_FILE , RECOVERY_COMMAND_DONE , FATAL ) ;
ereport ( FATAL ,
( errcode_for_file_access ( ) ,
errmsg ( " could not rename file \" %s \" to \" %s \" : %m " ,
RECOVERY_COMMAND_FILE , RECOVERY_COMMAND_DONE ) ) ) ;
ereport ( LOG ,
ereport ( LOG ,
( errmsg ( " archive recovery complete " ) ) ) ;
( errmsg ( " archive recovery complete " ) ) ) ;
@ -6190,7 +6168,7 @@ StartupXLOG(void)
if ( stat ( TABLESPACE_MAP , & st ) = = 0 )
if ( stat ( TABLESPACE_MAP , & st ) = = 0 )
{
{
unlink ( TABLESPACE_MAP_OLD ) ;
unlink ( TABLESPACE_MAP_OLD ) ;
if ( rename ( TABLESPACE_MAP , TABLESPACE_MAP_OLD ) = = 0 )
if ( durable_ rename( TABLESPACE_MAP , TABLESPACE_MAP_OLD , DEBUG1 ) = = 0 )
ereport ( LOG ,
ereport ( LOG ,
( errmsg ( " ignoring file \" %s \" because no file \" %s \" exists " ,
( errmsg ( " ignoring file \" %s \" because no file \" %s \" exists " ,
TABLESPACE_MAP , BACKUP_LABEL_FILE ) ,
TABLESPACE_MAP , BACKUP_LABEL_FILE ) ,
@ -6553,11 +6531,7 @@ StartupXLOG(void)
if ( haveBackupLabel )
if ( haveBackupLabel )
{
{
unlink ( BACKUP_LABEL_OLD ) ;
unlink ( BACKUP_LABEL_OLD ) ;
if ( rename ( BACKUP_LABEL_FILE , BACKUP_LABEL_OLD ) ! = 0 )
durable_rename ( BACKUP_LABEL_FILE , BACKUP_LABEL_OLD , FATAL ) ;
ereport ( FATAL ,
( errcode_for_file_access ( ) ,
errmsg ( " could not rename file \" %s \" to \" %s \" : %m " ,
BACKUP_LABEL_FILE , BACKUP_LABEL_OLD ) ) ) ;
}
}
/*
/*
@ -6570,11 +6544,7 @@ StartupXLOG(void)
if ( haveTblspcMap )
if ( haveTblspcMap )
{
{
unlink ( TABLESPACE_MAP_OLD ) ;
unlink ( TABLESPACE_MAP_OLD ) ;
if ( rename ( TABLESPACE_MAP , TABLESPACE_MAP_OLD ) ! = 0 )
durable_rename ( TABLESPACE_MAP , TABLESPACE_MAP_OLD , FATAL ) ;
ereport ( FATAL ,
( errcode_for_file_access ( ) ,
errmsg ( " could not rename file \" %s \" to \" %s \" : %m " ,
TABLESPACE_MAP , TABLESPACE_MAP_OLD ) ) ) ;
}
}
/* Check that the GUCs used to generate the WAL allow recovery */
/* Check that the GUCs used to generate the WAL allow recovery */
@ -7351,11 +7321,7 @@ StartupXLOG(void)
*/
*/
XLogArchiveCleanup ( partialfname ) ;
XLogArchiveCleanup ( partialfname ) ;
if ( rename ( origpath , partialpath ) ! = 0 )
durable_rename ( origpath , partialpath , ERROR ) ;
ereport ( ERROR ,
( errcode_for_file_access ( ) ,
errmsg ( " could not rename file \" %s \" to \" %s \" : %m " ,
origpath , partialpath ) ) ) ;
XLogArchiveNotify ( partialfname ) ;
XLogArchiveNotify ( partialfname ) ;
}
}
}
}
@ -10911,7 +10877,7 @@ CancelBackup(void)
/* remove leftover file from previously canceled backup if it exists */
/* remove leftover file from previously canceled backup if it exists */
unlink ( BACKUP_LABEL_OLD ) ;
unlink ( BACKUP_LABEL_OLD ) ;
if ( rename ( BACKUP_LABEL_FILE , BACKUP_LABEL_OLD ) ! = 0 )
if ( durable_ rename( BACKUP_LABEL_FILE , BACKUP_LABEL_OLD , DEBUG1 ) ! = 0 )
{
{
ereport ( WARNING ,
ereport ( WARNING ,
( errcode_for_file_access ( ) ,
( errcode_for_file_access ( ) ,
@ -10934,7 +10900,7 @@ CancelBackup(void)
/* remove leftover file from previously canceled backup if it exists */
/* remove leftover file from previously canceled backup if it exists */
unlink ( TABLESPACE_MAP_OLD ) ;
unlink ( TABLESPACE_MAP_OLD ) ;
if ( rename ( TABLESPACE_MAP , TABLESPACE_MAP_OLD ) = = 0 )
if ( durable_ rename( TABLESPACE_MAP , TABLESPACE_MAP_OLD , DEBUG1 ) = = 0 )
{
{
ereport ( LOG ,
ereport ( LOG ,
( errmsg ( " online backup mode canceled " ) ,
( errmsg ( " online backup mode canceled " ) ,