|
28 | 28 | *
|
29 | 29 | * As the percentage of transactions modifying the catalog normally is fairly
|
30 | 30 | * small in comparisons to ones only manipulating user data, we keep track of
|
31 |
| - * the committed catalog modifying ones inside (xmin, xmax) instead of keeping |
| 31 | + * the committed catalog modifying ones inside [xmin, xmax) instead of keeping |
32 | 32 | * track of all running transactions like it's done in a normal snapshot. Note
|
33 | 33 | * that we're generally only looking at transactions that have acquired an
|
34 | 34 | * xid. That is we keep a list of transactions between snapshot->(xmin, xmax)
|
@@ -1250,10 +1250,11 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn
|
1250 | 1250 | /* can decode everything after this */
|
1251 | 1251 | builder->start_decoding_at = lsn + 1;
|
1252 | 1252 |
|
1253 |
| - builder->xmin = running->oldestRunningXid; |
1254 |
| - builder->xmax = running->latestCompletedXid; |
1255 |
| - TransactionIdAdvance(builder->xmax); |
| 1253 | + /* As no transactions were running xmin/xmax can be trivially set. */ |
| 1254 | + builder->xmin = running->nextXid; /* < are finished */ |
| 1255 | + builder->xmax = running->nextXid; /* >= are running */ |
1256 | 1256 |
|
| 1257 | + /* so we can safely use the faster comparisons */ |
1257 | 1258 | Assert(TransactionIdIsNormal(builder->xmin));
|
1258 | 1259 | Assert(TransactionIdIsNormal(builder->xmax));
|
1259 | 1260 |
|
@@ -1294,9 +1295,14 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn
|
1294 | 1295 | * instead of running transactions we don't need to know anything
|
1295 | 1296 | * about uncommitted subtransactions.
|
1296 | 1297 | */
|
1297 |
| - builder->xmin = running->oldestRunningXid; |
1298 |
| - builder->xmax = running->latestCompletedXid; |
1299 |
| - TransactionIdAdvance(builder->xmax); |
| 1298 | + |
| 1299 | + /* |
| 1300 | + * Start with an xmin/xmax that's correct for future, when all the |
| 1301 | + * currently running transactions have finished. We'll update both |
| 1302 | + * while waiting for the pending transactions to finish. |
| 1303 | + */ |
| 1304 | + builder->xmin = running->nextXid; /* < are finished */ |
| 1305 | + builder->xmax = running->nextXid; /* >= are running */ |
1300 | 1306 |
|
1301 | 1307 | /* so we can safely use the faster comparisons */
|
1302 | 1308 | Assert(TransactionIdIsNormal(builder->xmin));
|
|
0 commit comments