@@ -1280,8 +1280,9 @@ SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn, xl_running_xact
12801280 ReorderBufferTXN * txn ;
12811281 TransactionId xmin ;
12821282
1283- builder -> csnSnapshotData .snapshotcsn = running -> csn ;
1284- builder -> csnSnapshotData .xmin = 0 ;
1283+ builder -> csnSnapshotData .snapshotcsn = running -> extension .csn ;
1284+ builder -> csnSnapshotData .xmin = running -> extension .runXmin ;
1285+ builder -> csnSnapshotData .nextXid = running -> extension .nextXid ;
12851286 builder -> csnSnapshotData .xlogptr = lsn ;
12861287
12871288 /*
@@ -1311,6 +1312,10 @@ SnapBuildProcessRunningXacts(SnapBuild *builder, XLogRecPtr lsn, xl_running_xact
13111312 * we hit fast paths in heapam_visibility.c.
13121313 */
13131314 builder -> xmin = running -> oldestRunningXid ;
1315+ builder -> csnSnapshotData .snapshotcsn = running -> extension .csn ;
1316+ builder -> csnSnapshotData .xmin = running -> extension .runXmin ;
1317+ builder -> csnSnapshotData .nextXid = running -> extension .nextXid ;
1318+ builder -> csnSnapshotData .xlogptr = lsn ;
13141319
13151320 /* Remove transactions we don't need to keep track off anymore */
13161321 SnapBuildPurgeOlderTxn (builder );
@@ -1439,7 +1444,8 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn
14391444 * NB: We might have already started to incrementally assemble a snapshot,
14401445 * so we need to be careful to deal with that.
14411446 */
1442- if (running -> oldestRunningXid == running -> nextXid )
1447+ if (running -> oldestRunningXid == running -> nextXid &&
1448+ running -> extension .runXmin == running -> extension .nextXid )
14431449 {
14441450 if (builder -> start_decoding_at == InvalidXLogRecPtr ||
14451451 builder -> start_decoding_at <= lsn )
@@ -1568,6 +1574,11 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn
15681574 return true;
15691575}
15701576
1577+ /*
1578+ * Hook for custom waits in SnapBuildWaitSnapshot() provided by extensions.
1579+ */
1580+ WaitSnapshotHookType waitSnapshotHook = NULL ;
1581+
15711582/* ---
15721583 * Iterate through xids in record, wait for all older than the cutoff to
15731584 * finish. Then, if possible, log a new xl_running_xacts record.
@@ -1602,6 +1613,12 @@ SnapBuildWaitSnapshot(xl_running_xacts *running, TransactionId cutoff)
16021613 XactLockTableWait (xid , NULL , NULL , XLTW_None );
16031614 }
16041615
1616+ /*
1617+ * Give extensions chance for their custom waits.
1618+ */
1619+ if (waitSnapshotHook )
1620+ waitSnapshotHook (& running -> extension );
1621+
16051622 /*
16061623 * All transactions we needed to finish finished - try to ensure there is
16071624 * another xl_running_xacts record in a timely manner, without having to
@@ -2209,9 +2226,8 @@ CheckPointSnapBuild(void)
22092226 FreeDir (snap_dir );
22102227}
22112228
2212- void
2213- SnapBuildUpdateCSNSnaphot (SnapBuild * builder ,
2214- CSNSnapshotData * csnSnapshotData )
2229+ CSNSnapshotData *
2230+ SnapBuildGetCSNSnaphot (SnapBuild * builder )
22152231{
2216- builder -> csnSnapshotData = * csnSnapshotData ;
2232+ return & builder -> csnSnapshotData ;
22172233}
0 commit comments