*** a/src/backend/access/transam/xlog.c
--- b/src/backend/access/transam/xlog.c
***************
*** 5351,5368 **** exitArchiveRecovery(TimeLineID endTLI, XLogSegNo endLogSegNo)
  	 * 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.
  	 */
  	if (endTLI != ThisTimeLineID)
  	{
  		XLogFileCopy(endLogSegNo, endTLI, endLogSegNo);
  
! 		if (XLogArchivingActive())
! 		{
! 			XLogFileName(xlogpath, endTLI, endLogSegNo);
! 			XLogArchiveNotify(xlogpath);
! 		}
  	}
  
  	/*
--- 5351,5367 ----
  	 * for the new timeline.
  	 *
  	 * Notify the archiver that the last WAL segment of the old timeline is
! 	 * 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 */
! 		XLogFileName(xlogpath, endTLI, endLogSegNo);
! 		XLogArchiveCheckDone(xlogpath);
  	}
  
  	/*
*** a/src/backend/access/transam/xlogarchive.c
--- b/src/backend/access/transam/xlogarchive.c
***************
*** 516,521 **** XLogArchiveNotify(const char *xlog)
--- 516,527 ----
  	char		archiveStatusPath[MAXPGPATH];
  	FILE	   *fd;
  
+ 	/*
+ 	 * We should not create .ready file for already archived WAL file to
+ 	 * prevent it from being archived again.
+ 	 */
+ 	Assert(XLogArchiveIsBusy(xlog));
+ 
  	/* insert an otherwise empty file called <XLOG>.ready */
  	StatusFilePath(archiveStatusPath, xlog, ".ready");
  	fd = AllocateFile(archiveStatusPath, "w");
