Subject: bt_recheck_sibling_links contrib/amcheck/verify_nbtree.c

From: jian he <[email-masked]>
Date: Mon, 24 Jul 2023 22:06:34 +0800

hi.
I am confused with bt_recheck_sibling_links.

>
>  ereport(ERROR,
>  (errcode(ERRCODE_INDEX_CORRUPTED),
>  errmsg("left link/right link pair in index \"%s\" not in agreement",
> RelationGetRelationName(state->rel)),
> errdetail_internal("Block=%u left block=%u left link from block=%u.",
> state->targetblock, leftcurrent,
> btpo_prev_from_target)));

should we put the above code into the branch {if (!state->readonly)} ?
I can understand it if put inside.
now the whole function be like:

if (!state->readonly)
{}
erreport{}.

---------------------------------------------------------------------------------
if (btpo_prev_from_target == leftcurrent)
{
/* Report split in left sibling, not target (or new target) */
ereport(DEBUG1,
(errcode(ERRCODE_INTERNAL_ERROR),
errmsg_internal("harmless concurrent page split detected in index \"%s\"",
RelationGetRelationName(state->rel)),
errdetail_internal("Block=%u new right sibling=%u original right sibling=%u.",
leftcurrent, newtargetblock,
state->targetblock)));
return;
}

only concurrency read case,  (btpo_prev_from_target == leftcurrent)
will be true? If so, then I am confused with the ereport content.