|
11 | 11 | * shared buffer content lock on the buffer containing the tuple.
|
12 | 12 | *
|
13 | 13 | * NOTE: When using a non-MVCC snapshot, we must check
|
14 |
| - * TransactionIdIsInProgress (which looks in the PGPROC array) |
15 |
| - * before TransactionIdDidCommit/TransactionIdDidAbort (which look in |
16 |
| - * pg_xact). Otherwise we have a race condition: we might decide that a |
17 |
| - * just-committed transaction crashed, because none of the tests succeed. |
18 |
| - * xact.c is careful to record commit/abort in pg_xact before it unsets |
19 |
| - * MyProc->xid in the PGPROC array. That fixes that problem, but it |
20 |
| - * also means there is a window where TransactionIdIsInProgress and |
21 |
| - * TransactionIdDidCommit will both return true. If we check only |
22 |
| - * TransactionIdDidCommit, we could consider a tuple committed when a |
23 |
| - * later GetSnapshotData call will still think the originating transaction |
24 |
| - * is in progress, which leads to application-level inconsistency. The |
25 |
| - * upshot is that we gotta check TransactionIdIsInProgress first in all |
26 |
| - * code paths, except for a few cases where we are looking at |
27 |
| - * subtransactions of our own main transaction and so there can't be any |
28 |
| - * race condition. |
| 14 | + * TransactionIdIsInProgress (which looks in the PGPROC array) before |
| 15 | + * TransactionIdDidCommit (which look in pg_xact). Otherwise we have a race |
| 16 | + * condition: we might decide that a just-committed transaction crashed, |
| 17 | + * because none of the tests succeed. xact.c is careful to record |
| 18 | + * commit/abort in pg_xact before it unsets MyProc->xid in the PGPROC array. |
| 19 | + * That fixes that problem, but it also means there is a window where |
| 20 | + * TransactionIdIsInProgress and TransactionIdDidCommit will both return true. |
| 21 | + * If we check only TransactionIdDidCommit, we could consider a tuple |
| 22 | + * committed when a later GetSnapshotData call will still think the |
| 23 | + * originating transaction is in progress, which leads to application-level |
| 24 | + * inconsistency. The upshot is that we gotta check TransactionIdIsInProgress |
| 25 | + * first in all code paths, except for a few cases where we are looking at |
| 26 | + * subtransactions of our own main transaction and so there can't be any race |
| 27 | + * condition. |
| 28 | + * |
| 29 | + * We can't use TransactionIdDidAbort here because it won't treat transactions |
| 30 | + * that were in progress during a crash as aborted. We determine that |
| 31 | + * transactions aborted/crashed through process of elimination instead. |
29 | 32 | *
|
30 | 33 | * When using an MVCC snapshot, we rely on XidInMVCCSnapshot rather than
|
31 | 34 | * TransactionIdIsInProgress, but the logic is otherwise the same: do not
|
|
0 commit comments