|
10 | 10 | * |
11 | 11 | * |
12 | 12 | * IDENTIFICATION |
13 | | - * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.200 2005/04/28 21:47:10 tgl Exp $ |
| 13 | + * $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.201 2005/05/19 21:35:45 tgl Exp $ |
14 | 14 | * |
15 | 15 | *------------------------------------------------------------------------- |
16 | 16 | */ |
|
34 | 34 | #include "miscadmin.h" |
35 | 35 | #include "storage/fd.h" |
36 | 36 | #include "storage/proc.h" |
37 | | -#include "storage/sinval.h" |
| 37 | +#include "storage/procarray.h" |
38 | 38 | #include "storage/smgr.h" |
39 | 39 | #include "utils/flatfiles.h" |
40 | 40 | #include "utils/guc.h" |
@@ -1503,24 +1503,26 @@ CommitTransaction(void) |
1503 | 1503 | * this must be done _before_ releasing locks we hold and _after_ |
1504 | 1504 | * RecordTransactionCommit. |
1505 | 1505 | * |
1506 | | - * LWLockAcquire(SInvalLock) is required: UPDATE with xid 0 is blocked by |
1507 | | - * xid 1' UPDATE, xid 1 is doing commit while xid 2 gets snapshot - if |
1508 | | - * xid 2' GetSnapshotData sees xid 1 as running then it must see xid 0 |
1509 | | - * as running as well or it will see two tuple versions - one deleted |
1510 | | - * by xid 1 and one inserted by xid 0. See notes in GetSnapshotData. |
| 1506 | + * LWLockAcquire(ProcArrayLock) is required; consider this example: |
| 1507 | + * UPDATE with xid 0 is blocked by xid 1's UPDATE. |
| 1508 | + * xid 1 is doing commit while xid 2 gets snapshot. |
| 1509 | + * If xid 2's GetSnapshotData sees xid 1 as running then it must see |
| 1510 | + * xid 0 as running as well, or it will be able to see two tuple versions |
| 1511 | + * - one deleted by xid 1 and one inserted by xid 0. See notes in |
| 1512 | + * GetSnapshotData. |
1511 | 1513 | */ |
1512 | 1514 | if (MyProc != NULL) |
1513 | 1515 | { |
1514 | | - /* Lock SInvalLock because that's what GetSnapshotData uses. */ |
1515 | | - LWLockAcquire(SInvalLock, LW_EXCLUSIVE); |
| 1516 | + /* Lock ProcArrayLock because that's what GetSnapshotData uses. */ |
| 1517 | + LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); |
1516 | 1518 | MyProc->xid = InvalidTransactionId; |
1517 | 1519 | MyProc->xmin = InvalidTransactionId; |
1518 | 1520 |
|
1519 | 1521 | /* Clear the subtransaction-XID cache too while holding the lock */ |
1520 | 1522 | MyProc->subxids.nxids = 0; |
1521 | 1523 | MyProc->subxids.overflowed = false; |
1522 | 1524 |
|
1523 | | - LWLockRelease(SInvalLock); |
| 1525 | + LWLockRelease(ProcArrayLock); |
1524 | 1526 | } |
1525 | 1527 |
|
1526 | 1528 | /* |
@@ -1688,16 +1690,16 @@ AbortTransaction(void) |
1688 | 1690 | */ |
1689 | 1691 | if (MyProc != NULL) |
1690 | 1692 | { |
1691 | | - /* Lock SInvalLock because that's what GetSnapshotData uses. */ |
1692 | | - LWLockAcquire(SInvalLock, LW_EXCLUSIVE); |
| 1693 | + /* Lock ProcArrayLock because that's what GetSnapshotData uses. */ |
| 1694 | + LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); |
1693 | 1695 | MyProc->xid = InvalidTransactionId; |
1694 | 1696 | MyProc->xmin = InvalidTransactionId; |
1695 | 1697 |
|
1696 | 1698 | /* Clear the subtransaction-XID cache too while holding the lock */ |
1697 | 1699 | MyProc->subxids.nxids = 0; |
1698 | 1700 | MyProc->subxids.overflowed = false; |
1699 | 1701 |
|
1700 | | - LWLockRelease(SInvalLock); |
| 1702 | + LWLockRelease(ProcArrayLock); |
1701 | 1703 | } |
1702 | 1704 |
|
1703 | 1705 | /* |
|
0 commit comments