diff options
author | Simon Riggs <simon@2ndQuadrant.com> | 2011-11-02 08:54:56 +0000 |
---|---|---|
committer | Simon Riggs <simon@2ndQuadrant.com> | 2011-11-02 08:54:56 +0000 |
commit | 86e33648992cfc104836ab1fbb6e654308beb4a5 (patch) | |
tree | c11d1ff97fea09f9bf20a961df11bebeb5316c5c /src/backend/access/transam/xlog.c | |
parent | 10b7c686e52a6d1bb10194ebf9331ef06f044d46 (diff) | |
download | postgresql-86e33648992cfc104836ab1fbb6e654308beb4a5.tar.gz postgresql-86e33648992cfc104836ab1fbb6e654308beb4a5.zip |
Derive oldestActiveXid at correct time for Hot Standby.
There was a timing window between when oldestActiveXid was derived
and when it should have been derived that only shows itself under
heavy load. Move code around to ensure correct timing of derivation.
No change to StartupSUBTRANS() code, which is where this failed.
Bug report by Chris Redekop
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r-- | src/backend/access/transam/xlog.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index bf57b3bf49e..0944aa4162d 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -7637,6 +7637,16 @@ CreateCheckPoint(int flags) checkPoint.time = (pg_time_t) time(NULL); /* + * For Hot Standby, derive the oldestActiveXid before we fix the redo pointer. + * This allows us to begin accumulating changes to assemble our starting + * snapshot of locks and transactions. + */ + if (!shutdown && XLogStandbyInfoActive()) + checkPoint.oldestActiveXid = GetOldestActiveTransactionId(); + else + checkPoint.oldestActiveXid = InvalidTransactionId; + + /* * We must hold WALInsertLock while examining insert state to determine * the checkpoint REDO pointer. */ @@ -7822,9 +7832,7 @@ CreateCheckPoint(int flags) * Update checkPoint.nextXid since we have a later value */ if (!shutdown && XLogStandbyInfoActive()) - LogStandbySnapshot(&checkPoint.oldestActiveXid, &checkPoint.nextXid); - else - checkPoint.oldestActiveXid = InvalidTransactionId; + LogStandbySnapshot(&checkPoint.nextXid); START_CRIT_SECTION(); |