public inbox for [email protected]
help / color / mirror / Atom feedFrom: Alexander Lakhin <[email protected]>
To: Michael Paquier <[email protected]>
To: Xuneng Zhou <[email protected]>
Cc: [email protected]
Subject: Re: BUG #18158: Assert in pgstat_report_stat() fails when a backend shutting down with stats pending
Date: Fri, 5 Jun 2026 08:00:00 +0300
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<[email protected]>
<CABPTF7XdDoLAoLKo7pOHmSqHniHf46Pw8Z=iqNx2uYi4J5ixBA@mail.gmail.com>
<[email protected]>
<CABPTF7VgzdBP_ZPKf2eZ79ry0fVKzcgCkB5gy60HGXCy0EQb0w@mail.gmail.com>
<[email protected]>
Hello Michael,
05.06.2026 05:14, Michael Paquier wrote:
> 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.
Please try the following:
--- a/src/backend/utils/activity/pgstat.c
+++ b/src/backend/utils/activity/pgstat.c
@@ -107,2 +107,3 @@
+#include "common/pg_prng.h"
@@ -1212,3 +1213,8 @@ pgstat_flush_pending_entries(bool nowait)
/* flush the stats, if possible */
+if (nowait && (pg_prng_double(&pg_global_prng_state) < 0.1))
+ did_flush = false;
+else
+{
did_flush = kind_info->flush_pending_cb(entry_ref, nowait);
+}
As far as I can see, that rand() gives the same sequence on macOS each run,
while on Linux I see different sequences.
The patch works for me test-wise.
Thank you for the fix!
Best regards,
Alexander
view thread (12+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: BUG #18158: Assert in pgstat_report_stat() fails when a backend shutting down with stats pending
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox