Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c111306

Browse files
XidEpoch++ if wraparound during checkpoint.
If wal_level = hot_standby we update the checkpoint nextxid, though in the case where a wraparound occurred half-way through a checkpoint we would neglect updating the epoch also. Updating the nextxid is arguably the wrong thing to do, but changing that may introduce subtle bugs into hot standby startup, while updating the value doesn't cause any known bugs yet. Minimal fix now to HEAD and backbranches, wider fix later in HEAD. Bug reported in #6291 by Daniel Farina and slightly differently in Cause analysis and recommended fixes from Tom Lane and Andres Freund. Applied patch is minimal version of Andres Freund's work.
1 parent 9f98704 commit c111306

File tree

1 file changed

+8
-1
lines changed
  • src/backend/access/transam

1 file changed

+8
-1
lines changed

src/backend/access/transam/xlog.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -7119,10 +7119,17 @@ CreateCheckPoint(int flags)
71197119
* If we are shutting down, or Startup process is completing crash
71207120
* recovery we don't need to write running xact data.
71217121
*
7122-
* Update checkPoint.nextXid since we have a later value
7122+
* Update checkPoint.nextXid since we may have a later value. If we
7123+
* do update the value, and we have wrapped, increment epoch also.
71237124
*/
71247125
if (!shutdown && XLogStandbyInfoActive())
7126+
{
7127+
TransactionId prevXid = checkPoint.nextXid;
7128+
71257129
LogStandbySnapshot(&checkPoint.nextXid);
7130+
if (checkPoint.nextXid < prevXid)
7131+
checkPoint.nextXidEpoch++;
7132+
}
71267133

71277134
START_CRIT_SECTION();
71287135

0 commit comments

Comments
 (0)