aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2012-11-19 10:02:25 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2012-11-19 10:14:20 +0200
commit644a0a6379afc00803dd89ffe8416514f5dfc217 (patch)
treeda387d3319795781f31d8448d2d101cead2e3151 /src/backend/access/transam/xlog.c
parentb6e3798f3aa2747db145f25e03a8d34f2e5ec8c8 (diff)
downloadpostgresql-644a0a6379afc00803dd89ffe8416514f5dfc217.tar.gz
postgresql-644a0a6379afc00803dd89ffe8416514f5dfc217.zip
Fix archive_cleanup_command.
When I moved ExecuteRecoveryCommand() from xlog.c to xlogarchive.c, I didn't realize that it's called from the checkpoint process, not the startup process. I tried to use InRedo variable to decide whether or not to attempt cleaning up the archive (must not do so before we have read the initial checkpoint record), but that variable is only valid within the startup process. Instead, let ExecuteRecoveryCommand() always clean up the archive, and add an explicit argument to RestoreArchivedFile() to say whether that's allowed or not. The caller knows better. Reported by Erik Rijkers, diagnosis by Fujii Masao. Only 9.3devel is affected.
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r--src/backend/access/transam/xlog.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 1faf666f43c..09d4dffc75e 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -2588,7 +2588,8 @@ XLogFileRead(XLogSegNo segno, int emode, TimeLineID tli,
restoredFromArchive = RestoreArchivedFile(path, xlogfname,
"RECOVERYXLOG",
- XLogSegSize);
+ XLogSegSize,
+ InRedo);
if (!restoredFromArchive)
return -1;
break;
@@ -9051,33 +9052,16 @@ GetXLogWriteRecPtr(void)
}
/*
- * Returns the redo pointer of the last restartpoint. This is the oldest
- * point in WAL that we still need, if we have to restart recovery. Returns
- * InvalidXLogRecPtr if we don't reliably know that point yet, that is,
- * before we have started WAL redo.
- *
- * This function only works in the startup process, and only while we are
- * in WAL redo. It's important to not return a value before redo has started,
- * to avoid deleting WAL files that we might still need, but there's no
- * fundamental reason why this couldn't return a valid value after redo has
- * finished, or in other processes. This is enough for the current usage,
- * however.
+ * Returns the redo pointer of the last checkpoint or restartpoint. This is
+ * the oldest point in WAL that we still need, if we have to restart recovery.
*/
void
GetOldestRestartPoint(XLogRecPtr *oldrecptr, TimeLineID *oldtli)
{
- if (InRedo)
- {
- LWLockAcquire(ControlFileLock, LW_SHARED);
- *oldrecptr = ControlFile->checkPointCopy.redo;
- *oldtli = ControlFile->checkPointCopy.ThisTimeLineID;
- LWLockRelease(ControlFileLock);
- }
- else
- {
- *oldrecptr = InvalidXLogRecPtr;
- *oldtli = 0;
- }
+ LWLockAcquire(ControlFileLock, LW_SHARED);
+ *oldrecptr = ControlFile->checkPointCopy.redo;
+ *oldtli = ControlFile->checkPointCopy.ThisTimeLineID;
+ LWLockRelease(ControlFileLock);
}
/*