mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
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.
This commit is contained in:
@ -13,7 +13,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.294 2004/10/07 14:19:58 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/vacuum.c,v 1.295 2004/10/15 22:39:56 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1190,6 +1190,12 @@ scan_heap(VRelStats *vacrelstats, Relation onerel,
|
||||
buf = ReadBuffer(onerel, blkno);
|
||||
page = BufferGetPage(buf);
|
||||
|
||||
/*
|
||||
* We don't bother to do LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE)
|
||||
* because we assume that holding exclusive lock on the relation
|
||||
* will keep other backends from looking at the page.
|
||||
*/
|
||||
|
||||
vacpage->blkno = blkno;
|
||||
vacpage->offsets_used = 0;
|
||||
vacpage->offsets_free = 0;
|
||||
@ -1235,7 +1241,6 @@ scan_heap(VRelStats *vacrelstats, Relation onerel,
|
||||
offnum <= maxoff;
|
||||
offnum = OffsetNumberNext(offnum))
|
||||
{
|
||||
uint16 sv_infomask;
|
||||
ItemId itemid = PageGetItemId(page, offnum);
|
||||
bool tupgone = false;
|
||||
|
||||
@ -1255,9 +1260,7 @@ scan_heap(VRelStats *vacrelstats, Relation onerel,
|
||||
tuple.t_len = ItemIdGetLength(itemid);
|
||||
ItemPointerSet(&(tuple.t_self), blkno, offnum);
|
||||
|
||||
sv_infomask = tuple.t_data->t_infomask;
|
||||
|
||||
switch (HeapTupleSatisfiesVacuum(tuple.t_data, OldestXmin))
|
||||
switch (HeapTupleSatisfiesVacuum(tuple.t_data, OldestXmin, buf))
|
||||
{
|
||||
case HEAPTUPLE_DEAD:
|
||||
tupgone = true; /* we can delete the tuple */
|
||||
@ -1348,10 +1351,6 @@ scan_heap(VRelStats *vacrelstats, Relation onerel,
|
||||
break;
|
||||
}
|
||||
|
||||
/* check for hint-bit update by HeapTupleSatisfiesVacuum */
|
||||
if (sv_infomask != tuple.t_data->t_infomask)
|
||||
pgchanged = true;
|
||||
|
||||
if (tupgone)
|
||||
{
|
||||
ItemId lpp;
|
||||
|
@ -31,7 +31,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.46 2004/09/30 23:21:19 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.47 2004/10/15 22:39:56 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -291,7 +291,6 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
|
||||
offnum = OffsetNumberNext(offnum))
|
||||
{
|
||||
ItemId itemid;
|
||||
uint16 sv_infomask;
|
||||
|
||||
itemid = PageGetItemId(page, offnum);
|
||||
|
||||
@ -307,9 +306,8 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
|
||||
ItemPointerSet(&(tuple.t_self), blkno, offnum);
|
||||
|
||||
tupgone = false;
|
||||
sv_infomask = tuple.t_data->t_infomask;
|
||||
|
||||
switch (HeapTupleSatisfiesVacuum(tuple.t_data, OldestXmin))
|
||||
switch (HeapTupleSatisfiesVacuum(tuple.t_data, OldestXmin, buf))
|
||||
{
|
||||
case HEAPTUPLE_DEAD:
|
||||
tupgone = true; /* we can delete the tuple */
|
||||
@ -364,10 +362,6 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
|
||||
break;
|
||||
}
|
||||
|
||||
/* check for hint-bit update by HeapTupleSatisfiesVacuum */
|
||||
if (sv_infomask != tuple.t_data->t_infomask)
|
||||
pgchanged = true;
|
||||
|
||||
if (tupgone)
|
||||
{
|
||||
lazy_record_dead_tuple(vacrelstats, &(tuple.t_self));
|
||||
@ -399,9 +393,9 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
|
||||
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
|
||||
|
||||
if (pgchanged)
|
||||
SetBufferCommitInfoNeedsSave(buf);
|
||||
|
||||
ReleaseBuffer(buf);
|
||||
WriteBuffer(buf);
|
||||
else
|
||||
ReleaseBuffer(buf);
|
||||
}
|
||||
|
||||
/* save stats for use later */
|
||||
@ -790,8 +784,7 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats)
|
||||
Page page;
|
||||
OffsetNumber offnum,
|
||||
maxoff;
|
||||
bool pgchanged,
|
||||
tupgone,
|
||||
bool tupgone,
|
||||
hastup;
|
||||
|
||||
vacuum_delay_point();
|
||||
@ -813,7 +806,6 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats)
|
||||
continue;
|
||||
}
|
||||
|
||||
pgchanged = false;
|
||||
hastup = false;
|
||||
maxoff = PageGetMaxOffsetNumber(page);
|
||||
for (offnum = FirstOffsetNumber;
|
||||
@ -821,7 +813,6 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats)
|
||||
offnum = OffsetNumberNext(offnum))
|
||||
{
|
||||
ItemId itemid;
|
||||
uint16 sv_infomask;
|
||||
|
||||
itemid = PageGetItemId(page, offnum);
|
||||
|
||||
@ -834,9 +825,8 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats)
|
||||
ItemPointerSet(&(tuple.t_self), blkno, offnum);
|
||||
|
||||
tupgone = false;
|
||||
sv_infomask = tuple.t_data->t_infomask;
|
||||
|
||||
switch (HeapTupleSatisfiesVacuum(tuple.t_data, OldestXmin))
|
||||
switch (HeapTupleSatisfiesVacuum(tuple.t_data, OldestXmin, buf))
|
||||
{
|
||||
case HEAPTUPLE_DEAD:
|
||||
tupgone = true; /* we can delete the tuple */
|
||||
@ -862,10 +852,6 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats)
|
||||
break;
|
||||
}
|
||||
|
||||
/* check for hint-bit update by HeapTupleSatisfiesVacuum */
|
||||
if (sv_infomask != tuple.t_data->t_infomask)
|
||||
pgchanged = true;
|
||||
|
||||
if (!tupgone)
|
||||
{
|
||||
hastup = true;
|
||||
@ -875,10 +861,7 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats)
|
||||
|
||||
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
|
||||
|
||||
if (pgchanged)
|
||||
WriteBuffer(buf);
|
||||
else
|
||||
ReleaseBuffer(buf);
|
||||
ReleaseBuffer(buf);
|
||||
|
||||
/* Done scanning if we found a tuple here */
|
||||
if (hastup)
|
||||
|
Reference in New Issue
Block a user