Re: pg19b1: TRAP: failed Assert("pgstat_bktype_io_stats_valid(bktype_shstats, MyBackendType)")

From: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
To: Andrey Rachitskiy <pl0h0yp1(at)gmail(dot)com>
Cc: Melanie Plageman <melanieplageman(at)gmail(dot)com>, Justin Pryzby <pryzby(at)telsasoft(dot)com>, pgsql-hackers mailing list <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: pg19b1: TRAP: failed Assert("pgstat_bktype_io_stats_valid(bktype_shstats, MyBackendType)")
Date: 2026-07-21 12:50:23
Message-ID: 51626C16-90D7-48D5-B828-CC0E37439C67@yandex-team.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrey asked me to look into the thread. I'm not an expert in AIO.

But I managed(using AI) to build a stable reproducer. I hope this helps a bit.

> On 17 Jul 2026, at 02:19, Andrey Rachitskiy <pl0h0yp1(at)gmail(dot)com> wrote:
>
> Between the two options you suggested for 19 — pass cnt = 1 for foreign IO in WaitReadBuffers(), or skip wait-time accounting on that path as in the patch I sent — I prefer the latter.
> Passing cnt = 1 would preserve the wait time, but it would also inflate reads for backends that only join an in-progress IO and never start that read.

+0.1 from me to skipping accounting. Passing cnt=1 would double-count the block
in the waiting backend, which already tracks it as a hit and as read by the
initiating backend.

PFA test and Andrey Rachitskiy's fix. Test is not intended for a commit, there
are more variables in this equation than I'm aware of.

Best regards, Andrey Borodin.

Attachment Content-Type Size
0001-Add-test-for-pg_stat_io-accounting-of-foreign-IO-wai.patch application/octet-stream 6.8 KB
0002-Don-t-count-foreign-IO-wait-time-as-read-time-in-pg_.patch application/octet-stream 1.8 KB
unknown_filename text/plain 2 bytes

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2026-07-21 13:07:33 Re: log_min_messages per backend type
Previous Message Matthias van de Meent 2026-07-21 12:24:13 Re: Unexpected behavior after OOM errors