If pg_stop_backup() is called just after switching to a new xlog file,
authorHeikki Linnakangas <heikki@enterprisedb.com>
Wed, 3 Dec 2008 08:20:11 +0000 (08:20 +0000)
committerHeikki Linnakangas <heikki@enterprisedb.com>
Wed, 3 Dec 2008 08:20:11 +0000 (08:20 +0000)
wait for the previous instead of the new file to be archived.

Based on patch by Simon Riggs.

src/backend/access/transam/xlog.c

index 0eeff6f7dbd8074a1bfe0a58d34e7b5037526c80..9c6a1e1dd6114ec8eb9c720cddf5156656482913 100644 (file)
@@ -6674,6 +6674,8 @@ pg_stop_backup(PG_FUNCTION_ARGS)
        char            histfilepath[MAXPGPATH];
        char            startxlogfilename[MAXFNAMELEN];
        char            stopxlogfilename[MAXFNAMELEN];
+       char            lastxlogfilename[MAXFNAMELEN];
+       char            histfilename[MAXFNAMELEN];
        uint32          _logId;
        uint32          _logSeg;
        FILE       *lfp;
@@ -6801,14 +6803,18 @@ pg_stop_backup(PG_FUNCTION_ARGS)
         * we assume the admin wanted his backup to work completely. If you
         * don't wish to wait, you can set statement_timeout.
         */
-       BackupHistoryFileName(histfilepath, ThisTimeLineID, _logId, _logSeg,
+       XLByteToPrevSeg(stoppoint, _logId, _logSeg);
+       XLogFileName(lastxlogfilename, ThisTimeLineID, _logId, _logSeg);
+
+       XLByteToSeg(startpoint, _logId, _logSeg);
+       BackupHistoryFileName(histfilename, ThisTimeLineID, _logId, _logSeg,
                                                  startpoint.xrecoff % XLogSegSize);
 
        seconds_before_warning = 60;
        waits = 0;
 
-       while (XLogArchiveIsBusy(stopxlogfilename) ||
-                  XLogArchiveIsBusy(histfilepath))
+       while (XLogArchiveIsBusy(lastxlogfilename) ||
+                  XLogArchiveIsBusy(histfilename))
        {
                CHECK_FOR_INTERRUPTS();