Skip to content

Commit 3d8d578

Browse files
Fix nbtree page deletion error messages.
Adjust some "can't happen" error messages that assumed that the page deletion target page must be a half-dead page. This assumption was wrong in the case of an internal target page. Simply refer to these pages as the target page instead. Internal pages are never marked half-dead. There is exactly one half-dead page for each subtree undergoing deletion. The half-dead page is also the target subtree's leaf-level page. This has been the case since commit efada2b, which totally overhauled nbtree page deletion.
1 parent d16f8c8 commit 3d8d578

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/backend/access/nbtree/nbtpage.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -2420,20 +2420,21 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, BlockNumber scanblkno,
24202420
* only one vacuum process running at a time.
24212421
*/
24222422
if (P_RIGHTMOST(opaque) || P_ISROOT(opaque) || P_ISDELETED(opaque))
2423-
elog(ERROR, "half-dead page changed status unexpectedly in block %u of index \"%s\"",
2423+
elog(ERROR, "target page changed status unexpectedly in block %u of index \"%s\"",
24242424
target, RelationGetRelationName(rel));
24252425

24262426
if (opaque->btpo_prev != leftsib)
24272427
ereport(ERROR,
24282428
(errcode(ERRCODE_INDEX_CORRUPTED),
2429-
errmsg_internal("left link changed unexpectedly in block %u of index \"%s\"",
2430-
target, RelationGetRelationName(rel))));
2429+
errmsg_internal("target page left link unexpectedly changed from %u to %u in block %u of index \"%s\"",
2430+
leftsib, opaque->btpo_prev, target,
2431+
RelationGetRelationName(rel))));
24312432

24322433
if (target == leafblkno)
24332434
{
24342435
if (P_FIRSTDATAKEY(opaque) <= PageGetMaxOffsetNumber(page) ||
24352436
!P_ISLEAF(opaque) || !P_ISHALFDEAD(opaque))
2436-
elog(ERROR, "half-dead page changed status unexpectedly in block %u of index \"%s\"",
2437+
elog(ERROR, "target leaf page changed status unexpectedly in block %u of index \"%s\"",
24372438
target, RelationGetRelationName(rel));
24382439

24392440
/* Leaf page is also target page: don't set leaftopparent */
@@ -2445,8 +2446,8 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, BlockNumber scanblkno,
24452446

24462447
if (P_FIRSTDATAKEY(opaque) != PageGetMaxOffsetNumber(page) ||
24472448
P_ISLEAF(opaque))
2448-
elog(ERROR, "half-dead page changed status unexpectedly in block %u of index \"%s\"",
2449-
target, RelationGetRelationName(rel));
2449+
elog(ERROR, "target internal page on level %u changed status unexpectedly in block %u of index \"%s\"",
2450+
targetlevel, target, RelationGetRelationName(rel));
24502451

24512452
/* Target is internal: set leaftopparent for next call here... */
24522453
itemid = PageGetItemId(page, P_FIRSTDATAKEY(opaque));

0 commit comments

Comments
 (0)