exitArchiveRecovery(TimeLineID endTLI, XLogSegNo endLogSegNo)
{
char recoveryPath[MAXPGPATH];
- char xlogpath[MAXPGPATH];
+ char xlogfname[MAXFNAMELEN];
/*
* We are no longer in archive recovery state.
* for the new timeline.
*
* Notify the archiver that the last WAL segment of the old timeline is
- * ready to copy to archival storage. Otherwise, it is not archived for a
- * while.
+ * ready to copy to archival storage if its .done file doesn't exist
+ * (e.g., if it's the restored WAL file, it's expected to have .done file).
+ * Otherwise, it is not archived for a while.
*/
if (endTLI != ThisTimeLineID)
{
XLogFileCopy(endLogSegNo, endTLI, endLogSegNo);
+ /* Create .ready file only when neither .ready nor .done files exist */
if (XLogArchivingActive())
{
- XLogFileName(xlogpath, endTLI, endLogSegNo);
- XLogArchiveNotify(xlogpath);
+ XLogFileName(xlogfname, endTLI, endLogSegNo);
+ XLogArchiveCheckDone(xlogfname);
}
}
* Let's just make real sure there are not .ready or .done flags posted
* for the new segment.
*/
- XLogFileName(xlogpath, ThisTimeLineID, endLogSegNo);
- XLogArchiveCleanup(xlogpath);
+ XLogFileName(xlogfname, ThisTimeLineID, endLogSegNo);
+ XLogArchiveCleanup(xlogfname);
/*
* Since there might be a partial WAL segment named RECOVERYXLOG, get rid