Re: Modernize error message for malformed B-Tree tuple posting

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Kirill Reshke <reshkekirill(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Modernize error message for malformed B-Tree tuple posting
Date: 2026-02-24 04:25:19
Message-ID: 0E7AC835-B654-4512-ACEB-1E8CB86722C3@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Feb 18, 2026, at 15:58, Kirill Reshke <reshkekirill(at)gmail(dot)com> wrote:
>
> Hi!
>
> Today, while routinely fixing corruptions reported by our monitoring,
> I observed a message:
>
> 2026-02-15 01:38:33.060
> MSK,"<cut>","<cut>",1725745,"localhost:51330",6990f425.1a5531,1,"UPDATE",2026-02-15
> 01:16:05 MSK,59/1760774,183431134,ERROR,XX000,"posting list tuple with
> 3 items cannot be split at offset 20",,,,,,"UPDATE .... <there was
> origin query,cut>,,,"","client backend",,3082007398573165030
>
>
> So, two things are bothering me here. First, this is XX000 and not
> XX002 which I cannot find a good reason to. Second, Index name is not
> present in the error message.
>
> Another about-corruption error messages seems to be different, for example:
>
> ERROR,XX002,"table tid from new index tuple (58084,119) overlaps with
> invalid duplicate tuple at offset 62 of block 181 in index ""<cut
> name>""",,,,,,"UPDATE <cut query>
>
> So, v1 changes the errcode for ERR_INDEX_CORRUPTION. For including
> index name, we need
> to pass relation to _bt_swap_posting function, which I did not do in
> v1, because I'm not sure changing is worth it.
>
> WDYT?
>
> --
> Best regards,
> Kirill Reshke
> <v1-0001-Modernize-error-message-for-malformed-B-Tree-tupl.patch>

Hi Kirill,

Thanks for the patch. It makes sense to me to replace elog with the more modern ereport() and to add a REINDEX hint.

One small thing: the hint message "Please REINDEX it" feels a bit ambiguous to me. I initially thought it would be better to include the index name in the hint, but then I noticed that _bt_swap_posting() doesn’t have access to the Relation, so it doesn’t know which index is affected.

If passing a Relation rel parameter down to this function isn’t acceptable, then maybe we could at least rephrase the hint to something like: “You might need to REINDEX the index.”, which sounds a bit clearer and avoids the vague “it”.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bryan Green 2026-02-24 04:31:55 Re: [PATCH] Add Windows support for backtrace_functions (MSVC only)
Previous Message Lukas Fittl 2026-02-24 04:18:34 Re: Stack-based tracking of per-node WAL/buffer usage