From: violin <1217816127@qq.com>
To: Manu <manuelreyesbravo@gmail.com>
To: pgsql-bugs <pgsql-bugs@lists.postgresql.org>
To: Michael Paquier <michael@paquier.xyz>
To: Tomas Vondra <tomas@vondra.me>
Cc: PG Bug reporting form <noreply@postgresql.org>
Subject: Re: BUG #19764: ManualBug3 Assert failure in pgstat_setup_shared_refs crashes initdb
Date: Sat, 17 Oct 2026 16:48:32 +0800
Message-ID: <tencent_F62706A391360C62257D0BED3F77BED58606@qq.com> (raw)
In-Reply-To: <179222073151.2432792.4555994957685675734@gmail.com>
References: <atGhar9gRh59yPuR@paquier.xyz>
<179222073151.2432792.4555994957685675734@gmail.com>
Sorry for the two-day delay in responding, and thank you for the detailed investigation.
I agree with your conclusion. The assertion failure was caused by my incremental build without dependency tracking, which left some `pgstat_*.o` files compiled against the old `PgStat_ShmemControl` layout. It was therefore a build artifact caused by stale object files, not a bug in PostgreSQL 19rc1 or master.
The line-number mismatch also confirms that the backtrace I reported did not come from the claimed REL_19_RC1 tree. I should have verified the exact source tree and reproduced the issue with a clean build before reporting it.
I apologize for the confusion and for the time spent investigating this. Please consider my original report withdrawn.
violin
1217816127@qq.com
Original
From: Manu <manuelreyesbravo@gmail.com>
Date: 2026-10-17 15:05
To: pgsql-bugs <pgsql-bugs@lists.postgresql.org>, Michael Paquier <michael@paquier.xyz>, Tomas Vondra <tomas@vondra.me>
Cc: 1217816127 <1217816127@qq.com>, PG Bug reporting form <noreply@postgresql.org>
Subject: Re: BUG #19764: ManualBug3 Assert failure in pgstat_setup_shared_refs crashes initdb
On Fri, Oct 16, 2026 at 1:00 PM Michael Paquier wrote:
> These code paths run under initdb in the buildfarm and the CI on a
> daily basis hundreds of times or even more than that. Of course
> there could be a bug, but I just suspect a false positive.
I ran controlled builds to settle the clean vs incremental build question.
Clean builds (git clean -fdx; ./configure --enable-cassert --enable-debug
--enable-depend; make; make install), initdb run 50 times serially and 50 times
8-way parallel on each:
REL_19_RC1 (0b8bff042a), REL_19_STABLE (58d16be8ac), master (23e7ca78a0)
and 44539786b8: 400/400 OK, no assertion failure.
Incremental build as Tomas described (build at 44539786b8^, check out
44539786b8, make again, configured without --enable-depend): initdb fails
10/10 with
TRAP: failed Assert("pgStatSharedRefAge != 0"), File: "pgstat_shmem.c", Line: 505
The same incremental update with --enable-depend: 100/100 OK.
What goes wrong: 44539786b8 adds kind_hash_handles[] and raw_kind_dsa_area[]
to PgStat_ShmemControl ahead of is_shutdown, which moves gc_request_count from
offset 24 to 552. Without dependency tracking, only pgstat.o and pgstat_shmem.o
get rebuilt; the other pgstat_*.o keep the old layout. The stale
pgstat_archiver_reset_all_cb() still addresses archiver at shmem+288, so its
reset_offset covers 448..584, which now includes gc_request_count. When there
is no stats file, pgstat_restore_stats() -> pgstat_reset_after_failure() calls
that callback, it copies the (zero) stats over reset_offset, and
gc_request_count drops from 1 to 0. That is the sequence in the report; with gdb
I see gc_request_count = 1 on entry to pgstat_archiver_reset_all_cb and 0 in the
next pgstat_setup_shared_refs(). With a clean build the same callback runs and
the counter stays at 1.
Leaving only pgstat_archiver.o stale reproduces it 20/20. Rebuilding only
pgstat_archiver.o makes this assertion go away, but then the other stale objects
corrupt other parts of shared memory (Assert("list->head != procno") in
proclist.h), so a tree in that state isn't usable at all.
So I agree with Tomas and Michael: this is a build artifact, not a bug in 19rc1
or master. 44539786b8 is only on master, and in 19rc1 this assertion is at
pgstat_shmem.c:391, so the trace in the report seems to come from a different
tree than 19rc1.
Regards,
Manu
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: 1217816127@qq.com, manuelreyesbravo@gmail.com, michael@paquier.xyz, tomas@vondra.me, noreply@postgresql.org
Subject: Re: BUG #19764: ManualBug3 Assert failure in pgstat_setup_shared_refs crashes initdb
In-Reply-To: <tencent_F62706A391360C62257D0BED3F77BED58606@qq.com>
References: <atGhar9gRh59yPuR@paquier.xyz> <179222073151.2432792.4555994957685675734@gmail.com> <tencent_F62706A391360C62257D0BED3F77BED58606@qq.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox