From 37689fbc79bea6d0ea982322157de65fd6b70a8d Mon Sep 17 00:00:00 2001 From: Andrey Borodin Date: Thu, 5 Mar 2026 08:59:07 +0500 Subject: [PATCH v4 4/5] amcheck: address review - fix Bloom filter comment, add table name to errors - Rephrase Bloom filter comment: filters have false positives, never false negatives, so "not in" correctly means we must verify - Include table name in indexallkeysmatch error messages for easier diagnosis --- contrib/amcheck/verify_nbtree.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/contrib/amcheck/verify_nbtree.c b/contrib/amcheck/verify_nbtree.c index 29ce35dcd6c..730358aa02a 100644 --- a/contrib/amcheck/verify_nbtree.c +++ b/contrib/amcheck/verify_nbtree.c @@ -2981,8 +2981,10 @@ bt_verify_index_tuple_points_to_heap(BtreeCheckState *state, IndexTuple itup, /* * Bloom filter says (key, tid) not in heap. Follow TID to verify; this - * amortizes random heap lookups when the filter has false negatives, or - * reports corruption when the index points to wrong heap tuple. + * amortizes random heap lookups by only fetching when the probe indicates + * absence (Bloom filters have false positives, never false negatives, so + * "not in" means we must verify), or reports corruption when the index + * points to wrong heap tuple. * * Use SnapshotAny first to distinguish "tuple doesn't exist" (corruption) * from "tuple exists but is dead" (skip). SnapshotAny returns any tuple @@ -3007,8 +3009,9 @@ bt_verify_index_tuple_points_to_heap(BtreeCheckState *state, IndexTuple itup, ExecDropSingleTupleTableSlot(slot); ereport(ERROR, (errcode(ERRCODE_INDEX_CORRUPTED), - errmsg("index tuple in index \"%s\" points to non-existent heap tuple", - RelationGetRelationName(state->rel)), + errmsg("index tuple in index \"%s\" points to non-existent heap tuple in table \"%s\"", + RelationGetRelationName(state->rel), + RelationGetRelationName(state->heaprel)), errdetail_internal("Index tid=(%u,%u) points to heap tid=(%u,%u) that no longer exists.", targetblock, offset, ItemPointerGetBlockNumber(tid), @@ -3048,8 +3051,9 @@ bt_verify_index_tuple_points_to_heap(BtreeCheckState *state, IndexTuple itup, pfree(norm); ereport(ERROR, (errcode(ERRCODE_INDEX_CORRUPTED), - errmsg("index tuple in index \"%s\" does not match heap tuple", - RelationGetRelationName(state->rel)), + errmsg("index tuple in index \"%s\" does not match heap tuple in table \"%s\"", + RelationGetRelationName(state->rel), + RelationGetRelationName(state->heaprel)), errdetail_internal("Index tid=(%u,%u) points to heap tid=(%u,%u) with different key.", targetblock, offset, ItemPointerGetBlockNumber(tid), -- 2.51.2