Re: Odd usage of errmsg_internal in bufmgr.c

From: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Álvaro Herrera <alvherre(at)kurilemu(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Odd usage of errmsg_internal in bufmgr.c
Date: 2026-02-12 20:25:19
Message-ID: CAN4CZFO=YZQQQp7XKyqc2u5wrb_ow1Rqk8a0Mtpe3nGaiN+Q3g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> No, I don't think so. This is just about errors on the bufmgr layer.

I see. Looks like I misinterpreted the comment in md.c where it sets
this flag when it reads 0 blocks.

> I apparently may be alone in this, but I find 6 repetitions of ereports, with
> differently indented messages and arguments, depending on whether it's an
> errmsg, errdetails, errhint way harder to scan and modify than something that
> just shows the different messages with consistent indentation.

Is changing the messages to follow the same pattern an option?

For example the error messages:

"read error in block %u of relation \"%s\": %s"
"%u read errors among blocks %u..%u of relation \"%s\": %s"

When the last string is conditional:

* invalid page(s)
* zeroing out invalid page(s)
* ignoring checksum error(s)

or maybe

"read error: %s in block %u of relation \"%s\""

errdetail would use a generic description (first faulty page?)
errhint could stay the same (maybe with errhint_plural?)

And that would simplify the ifs:

if (result.status == PGAIO_RS_ERROR)
{
affected_count = zeroed_or_error_count;
msg_action = affected_count > 1 ? "invalid pages" : "invalid page";
}

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marcos Pegoraro 2026-02-12 20:27:31 Re: Add CREATE SCHEMA ... LIKE support
Previous Message Andres Freund 2026-02-12 20:12:50 Re: Changing shared_buffers without restart