Skip to content

Commit 14d7f55

Browse files
x4mhackorum
authored andcommitted
Detect hintbit contradictions to commit log
Currently, under some corruption stated freezing can emit ereports like "cannot freeze committed xmax". This change helps to detect such conditions.
1 parent b597835 commit 14d7f55

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

contrib/amcheck/verify_heapam.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,12 @@ check_tuple_visibility(HeapCheckContext *ctx, bool *xmin_commit_status_ok,
13181318
return false;
13191319
}
13201320
}
1321+
else if (xmin_status != XID_COMMITTED)
1322+
{
1323+
report_corruption(ctx,
1324+
psprintf("uncommitted xmin %u while tuple has HEAP_XMIN_COMMITTED flag",
1325+
xmin));
1326+
}
13211327

13221328
/*
13231329
* Okay, the inserter committed, so it was good at some point. Now what
@@ -1379,6 +1385,14 @@ check_tuple_visibility(HeapCheckContext *ctx, bool *xmin_commit_status_ok,
13791385
* toast cannot be vacuumed out from under us.
13801386
*/
13811387
ctx->tuple_could_be_pruned = false;
1388+
1389+
if (xmax_status == XID_COMMITTED && (tuphdr->t_infomask & HEAP_UPDATED))
1390+
{
1391+
report_corruption(ctx,
1392+
psprintf("committed xmax %u while tuple has HEAP_XMAX_INVALID and HEAP_UPDATED flags",
1393+
xmax));
1394+
}
1395+
13821396
return true;
13831397
}
13841398

0 commit comments

Comments
 (0)