diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-10-15 22:40:29 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-10-15 22:40:29 +0000 |
commit | 9ffc8ed58b55cb3925bb95cc184583fcb9772013 (patch) | |
tree | 9039f51525070c611a86f03a2e85a13b24005ac3 /src/backend/access | |
parent | db9e2fd0a9144707055ed382f184f5a9c11aafff (diff) | |
download | postgresql-9ffc8ed58b55cb3925bb95cc184583fcb9772013.tar.gz postgresql-9ffc8ed58b55cb3925bb95cc184583fcb9772013.zip |
Repair possible failure to update hint bits back to disk, per
http://archives.postgresql.org/pgsql-hackers/2004-10/msg00464.php.
This fix is intended to be permanent: it moves the responsibility for
calling SetBufferCommitInfoNeedsSave() into the tqual.c routines,
eliminating the requirement for callers to test whether t_infomask changed.
Also, tighten validity checking on buffer IDs in bufmgr.c --- several
routines were paranoid about out-of-range shared buffer numbers but not
about out-of-range local ones, which seems a tad pointless.
Diffstat (limited to 'src/backend/access')
-rw-r--r-- | src/backend/access/heap/heapam.c | 18 | ||||
-rw-r--r-- | src/backend/access/index/indexam.c | 14 | ||||
-rw-r--r-- | src/backend/access/nbtree/nbtinsert.c | 12 |
3 files changed, 16 insertions, 28 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index b9a6072c799..af5325ea632 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.178 2004/10/12 21:54:34 petere Exp $ + * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.179 2004/10/15 22:39:42 tgl Exp $ * * * INTERFACE ROUTINES @@ -1314,7 +1314,7 @@ heap_delete(Relation relation, ItemPointer tid, tp.t_tableOid = relation->rd_id; l1: - result = HeapTupleSatisfiesUpdate(tp.t_data, cid); + result = HeapTupleSatisfiesUpdate(tp.t_data, cid, buffer); if (result == HeapTupleInvisible) { @@ -1331,7 +1331,7 @@ l1: XactLockTableWait(xwait); LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE); - if (TransactionIdDidAbort(xwait)) + if (!TransactionIdDidCommit(xwait)) goto l1; /* @@ -1356,7 +1356,7 @@ l1: if (crosscheck != InvalidSnapshot && result == HeapTupleMayBeUpdated) { /* Perform additional check for serializable RI updates */ - if (!HeapTupleSatisfiesSnapshot(tp.t_data, crosscheck)) + if (!HeapTupleSatisfiesSnapshot(tp.t_data, crosscheck, buffer)) result = HeapTupleUpdated; } @@ -1543,7 +1543,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup, */ l2: - result = HeapTupleSatisfiesUpdate(oldtup.t_data, cid); + result = HeapTupleSatisfiesUpdate(oldtup.t_data, cid, buffer); if (result == HeapTupleInvisible) { @@ -1560,7 +1560,7 @@ l2: XactLockTableWait(xwait); LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE); - if (TransactionIdDidAbort(xwait)) + if (!TransactionIdDidCommit(xwait)) goto l2; /* @@ -1585,7 +1585,7 @@ l2: if (crosscheck != InvalidSnapshot && result == HeapTupleMayBeUpdated) { /* Perform additional check for serializable RI updates */ - if (!HeapTupleSatisfiesSnapshot(oldtup.t_data, crosscheck)) + if (!HeapTupleSatisfiesSnapshot(oldtup.t_data, crosscheck, buffer)) result = HeapTupleUpdated; } @@ -1871,7 +1871,7 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer, tuple->t_len = ItemIdGetLength(lp); l3: - result = HeapTupleSatisfiesUpdate(tuple->t_data, cid); + result = HeapTupleSatisfiesUpdate(tuple->t_data, cid, *buffer); if (result == HeapTupleInvisible) { @@ -1888,7 +1888,7 @@ l3: XactLockTableWait(xwait); LockBuffer(*buffer, BUFFER_LOCK_EXCLUSIVE); - if (TransactionIdDidAbort(xwait)) + if (!TransactionIdDidCommit(xwait)) goto l3; /* diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c index 7c698fb48a2..214f646276b 100644 --- a/src/backend/access/index/indexam.c +++ b/src/backend/access/index/indexam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.75 2004/09/30 23:21:14 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/access/index/indexam.c,v 1.76 2004/10/15 22:39:46 tgl Exp $ * * INTERFACE ROUTINES * index_open - open an index relation by relation OID @@ -497,7 +497,6 @@ index_getnext(IndexScanDesc scan, ScanDirection direction) for (;;) { bool found; - uint16 sv_infomask; pgstat_count_index_scan(&scan->xs_pgstat_info); @@ -541,19 +540,14 @@ index_getnext(IndexScanDesc scan, ScanDirection direction) * index AM to not return it on future indexscans. * * We told heap_release_fetch to keep a pin on the buffer, so we can - * re-access the tuple here. But we must re-lock the buffer - * first. Also, it's just barely possible for an update of hint - * bits to occur here. + * re-access the tuple here. But we must re-lock the buffer first. */ LockBuffer(scan->xs_cbuf, BUFFER_LOCK_SHARE); - sv_infomask = heapTuple->t_data->t_infomask; - if (HeapTupleSatisfiesVacuum(heapTuple->t_data, RecentGlobalXmin) == - HEAPTUPLE_DEAD) + if (HeapTupleSatisfiesVacuum(heapTuple->t_data, RecentGlobalXmin, + scan->xs_cbuf) == HEAPTUPLE_DEAD) scan->kill_prior_tuple = true; - if (sv_infomask != heapTuple->t_data->t_infomask) - SetBufferCommitInfoNeedsSave(scan->xs_cbuf); LockBuffer(scan->xs_cbuf, BUFFER_LOCK_UNLOCK); } diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c index 815e207fb2f..32615a62c27 100644 --- a/src/backend/access/nbtree/nbtinsert.c +++ b/src/backend/access/nbtree/nbtinsert.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.116 2004/08/29 05:06:40 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.117 2004/10/15 22:39:49 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -261,19 +261,13 @@ _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel, * marked killed. This logic should match * index_getnext and btgettuple. */ - uint16 sv_infomask; - LockBuffer(hbuffer, BUFFER_LOCK_SHARE); - sv_infomask = htup.t_data->t_infomask; - if (HeapTupleSatisfiesVacuum(htup.t_data, - RecentGlobalXmin) == - HEAPTUPLE_DEAD) + if (HeapTupleSatisfiesVacuum(htup.t_data, RecentGlobalXmin, + hbuffer) == HEAPTUPLE_DEAD) { curitemid->lp_flags |= LP_DELETE; SetBufferCommitInfoNeedsSave(buf); } - if (sv_infomask != htup.t_data->t_infomask) - SetBufferCommitInfoNeedsSave(hbuffer); LockBuffer(hbuffer, BUFFER_LOCK_UNLOCK); ReleaseBuffer(hbuffer); } |