mirror of
https://github.com/postgres/postgres.git
synced 2025-11-12 05:01:15 +03:00
Fix hash index vs "snapshot too old" problemms
Hash indexes are not WAL-logged, and so do not maintain the LSN of index pages. Since the "snapshot too old" feature counts on detecting error conditions using the LSN of a table and all indexes on it, this makes it impossible to safely do early vacuuming on any table with a hash index, so add this to the tests for whether the xid used to vacuum a table can be adjusted based on old_snapshot_threshold. While at it, add a paragraph to the docs for old_snapshot_threshold which specifically mentions this and other aspects of the feature which may otherwise surprise users. Problem reported and patch reviewed by Amit Kapila
This commit is contained in:
@@ -279,7 +279,6 @@ hashgettuple(IndexScanDesc scan, ScanDirection dir)
|
||||
buf = so->hashso_curbuf;
|
||||
Assert(BufferIsValid(buf));
|
||||
page = BufferGetPage(buf);
|
||||
TestForOldSnapshot(scan->xs_snapshot, rel, page);
|
||||
maxoffnum = PageGetMaxOffsetNumber(page);
|
||||
for (offnum = ItemPointerGetOffsetNumber(current);
|
||||
offnum <= maxoffnum;
|
||||
|
||||
@@ -189,7 +189,6 @@ _hash_first(IndexScanDesc scan, ScanDirection dir)
|
||||
/* Read the metapage */
|
||||
metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_READ, LH_META_PAGE);
|
||||
page = BufferGetPage(metabuf);
|
||||
TestForOldSnapshot(scan->xs_snapshot, rel, page);
|
||||
metap = HashPageGetMeta(page);
|
||||
|
||||
/*
|
||||
@@ -243,7 +242,6 @@ _hash_first(IndexScanDesc scan, ScanDirection dir)
|
||||
/* Fetch the primary bucket page for the bucket */
|
||||
buf = _hash_getbuf(rel, blkno, HASH_READ, LH_BUCKET_PAGE);
|
||||
page = BufferGetPage(buf);
|
||||
TestForOldSnapshot(scan->xs_snapshot, rel, page);
|
||||
opaque = (HashPageOpaque) PageGetSpecialPointer(page);
|
||||
Assert(opaque->hasho_bucket == bucket);
|
||||
|
||||
@@ -350,7 +348,6 @@ _hash_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir)
|
||||
_hash_readnext(rel, &buf, &page, &opaque);
|
||||
if (BufferIsValid(buf))
|
||||
{
|
||||
TestForOldSnapshot(scan->xs_snapshot, rel, page);
|
||||
maxoff = PageGetMaxOffsetNumber(page);
|
||||
offnum = _hash_binsearch(page, so->hashso_sk_hash);
|
||||
}
|
||||
@@ -392,7 +389,6 @@ _hash_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir)
|
||||
_hash_readprev(rel, &buf, &page, &opaque);
|
||||
if (BufferIsValid(buf))
|
||||
{
|
||||
TestForOldSnapshot(scan->xs_snapshot, rel, page);
|
||||
maxoff = PageGetMaxOffsetNumber(page);
|
||||
offnum = _hash_binsearch_last(page, so->hashso_sk_hash);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user