Re: BUG #18158: Assert in pgstat_report_stat() fails when a backend shutting down with stats pending

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
Cc: Alexander Lakhin <exclusion(at)gmail(dot)com>, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18158: Assert in pgstat_report_stat() fails when a backend shutting down with stats pending
Date: 2026-06-05 02:14:31
Message-ID: aiIxB2oawj8pZeON@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, May 14, 2026 at 03:19:34PM +0800, Xuneng Zhou wrote:
> I agree that applying the change wholesale could be too invasive. If
> we decide not to address the ordering issue, removing this assertion
> seems reasonable, since the non-assert path does not actually provide
> the required guarantee.

Attached is a patch for 15~17 that is able to achieve this goal:
- Lift the assertion on shutdown for WAL senders, but keep it
everywhere else.
- Secondary trick in pgstat_shutdown_hook to cope with the fact that
some stats make still be around at shutdown for a WAL sender.

I cannot reproduce the failure re-using the trick sent by Alexander at
the top of the thread.

Thoughts or objections?
--
Michael

Attachment Content-Type Size
0001-Lift-shutdown-assertion-in-pgstats-for-WAL-senders.patch text/plain 1.7 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Fujii Masao 2026-06-05 03:18:49 Re: BUG #19508: pg_buffercache_pages() crashes the backend with an incompatible caller-supplied record definition
Previous Message PG Bug reporting form 2026-06-05 01:49:46 BUG #19512: PG 17.10: SIGSEGV in build_minmax_path (planner) and hash_bytes (HashAgg executor)