Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wMtHy-000QDO-2E for pgsql-bugs@arkaria.postgresql.org; Tue, 12 May 2026 20:01:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wMtGx-005dvP-00 for pgsql-bugs@arkaria.postgresql.org; Tue, 12 May 2026 20:00:07 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wMtGw-005dvH-20 for pgsql-bugs@lists.postgresql.org; Tue, 12 May 2026 20:00:06 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wMtGt-00000000FsS-3T70 for pgsql-bugs@lists.postgresql.org; Tue, 12 May 2026 20:00:05 +0000 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-44dd5cb0f81so4500303f8f.0 for ; Tue, 12 May 2026 13:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778616003; x=1779220803; darn=lists.postgresql.org; h=in-reply-to:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=cPM2tHRFbgcjjQ3M5LIY2B/SL0k8hzFh7E9XqZ/IsVQ=; b=Nz+5WQs+FKu6PoLAVC/NW3lP/kjKQtOLYFKM4mQRskGmpfJ1EFIOySd+msfNd3z/q8 MXOf6Gmr+39UxYci4vjImhSxsiiDRxZzFQMmmEhefHhL3NXen//jImi29+I04Lfi+V63 iQIM144n6CK15VSii6BQpABMzH1zLkS4IWzZ1l8JurR9rU9cY9lxIIHkATW5sqrtMFtl uQzBAlVC5QJfH8GPUuwN+81qnV+kQ96oJ1ib7SG+yDSoODn6+Qma/2miE2sqcie1rCQ5 94OPPUWadizIbbxWppbY0fnCrQOF/5XFIefbcIobYnXWAz0u6Kcs9eTdHptXwbB1e0Wb C0tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778616003; x=1779220803; h=in-reply-to:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cPM2tHRFbgcjjQ3M5LIY2B/SL0k8hzFh7E9XqZ/IsVQ=; b=jeUeiNTEohbs+np+lTLeyrFQp5t1WDlraYZruTX5O51aWoYDx5N48z+oaDeX+Rsd96 mJoPNeImnw54IL4aKZ6fCt7aUCflixKnC1WNx7a3gfk1i8+gWncB+QfmgPQ8V9awXc9h bbJQA/dcp/5a+zstU72AXW/QKQNMnq9X6jl+62elhwrA50f97f3uM3ySQS3HLivKW/XB 6eArKMJwr4ouwP+QZR0eKl0cjxRlzAhL9Ui1vugFeI1QGZcrATyz2hfxpnE9MhlxL3aC PBoH7Zb+NzlMHawuupZmVOLZwZDio8DgHbBV2ETxWMMr5ssGYnoEKx34+hyycgujMr+s 8Nmw== X-Gm-Message-State: AOJu0YzMlTVXpHugbVM2dh3kzoTfJEcsUn7CQukrVPBQXWxDbRPBHqlP 5ubilb2nISwu50Mt4yz6DkMc1KISHSqiYVgytp7azDAmUzxdDElKv89wh/Suyw== X-Gm-Gg: Acq92OFWjoBKN5BRMbdRl72PEZg6/Ec34NvfQzyY4SgHvdPs68t1jfO8VViJ1eZ4EpW wl4hoqUXQmyln2Mh/0iZ4nxk5XzxifoOKFXjH5Qq8wV8apnmvv4fj/qclUub41tMUJDPU1F/p61 bnpV0ozCKSWmHcW/esSF6RQvpOwzEGkANxN62g+fPxHZh3f7MHspYY7qMnopPXh/0KIzeHxS+gv f3bWU9ZP2R6NQFCOXtUyLYvvbZcv7O1tvAKgzVUzp8O+VGsZDjq4Z8ZS7JtHvJpl8HfUdFqV3Pz oH7Y3vlP5t4y5yGWF//HFYa1PvOLarRBoiIIGEAJMvZgYPEkeqSRoCq/EKxOn9Jy4vEdRpaUEDM UCQmednX8OykxwJz5RAjBr4acqrybgm1xcrRhmkd3TVZks93AWjkgxtqbMqRTq7G1GLhSid2jTf mDXI/dzD3+YPGNG/WH0ObYgSz5q8kr33DAb5c= X-Received: by 2002:a05:6000:1612:b0:43f:df55:fe5e with SMTP id ffacd0b85a97d-45abda0fe7bmr5891546f8f.0.1778616002648; Tue, 12 May 2026 13:00:02 -0700 (PDT) Received: from [192.168.0.50] ([89.149.68.143]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45ba2aaec3asm5098040f8f.15.2026.05.12.13.00.01 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 May 2026 13:00:01 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------sND80aAPB7VNlvPmWXwSXhlc" Message-ID: <58b5d6bf-7dca-41e5-8000-e12981205ada@gmail.com> Date: Tue, 12 May 2026 23:00:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BUG #18158: Assert in pgstat_report_stat() fails when a backend shutting down with stats pending To: pgsql-bugs@lists.postgresql.org References: <18158-88f667028dbc7e7b@postgresql.org> Content-Language: en-US From: Alexander Lakhin In-Reply-To: <18158-88f667028dbc7e7b@postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------sND80aAPB7VNlvPmWXwSXhlc Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hello hackers, 16.10.2023 12:00, PG Bug reporting form wrote: > The following bug has been logged on the website: > > Bug reference: 18158 > Logged by: Alexander Lakhin > Email address:exclusion@gmail.com > PostgreSQL version: 16.0 > Operating system: Ubuntu 22.04 > Description: > ... > With the following modification in pgstat_flush_pending_entries(): > +if (nowait && (rand() % 10 == 0)) > + did_flush = false; > +else > +{ > did_flush = kind_info->flush_pending_cb(entry_ref, nowait); > +} > > the issue reproduced easily: > make -s check -C src/test/recovery/ PROVE_TESTS="t/012_subtransactions.pl" > grep TRAP -r src/test/recovery/tmp_check/log > > # +++ tap check in src/test/recovery +++ > t/012_subtransactions.pl .. ok > All tests successful. > Files=1, Tests=12, 3 wallclock secs ( 0.01 usr 0.00 sys + 0.19 cusr 0.27 > csys = 0.47 CPU) > Result: PASS > src/test/recovery/tmp_check/log/012_subtransactions_primary.log: > TRAP: failed Assert("!pgStatLocal.shmem->is_shutdown"), File: "pgstat.c", > Line: 616, PID: 2410126 It looks like skink produced this failure yesterday [1]: 241/316 recovery - postgresql:recovery/027_stream_regress ERROR           4374.08s   exit status 1 ... stderr: #   Failed test 'check contents of pg_stat_statements on regression database' #   at /home/bf/bf-build/skink/REL_17_STABLE/pgsql/src/test/recovery/t/027_stream_regress.pl line 177. #          got: 'CREATE|f # SELECT|t' #     expected: 'CREATE|t # DELETE|t # INSERT|t # SELECT|t # UPDATE|t' # Looks like you failed 1 test of 9.  pgsql.build/testrun/recovery/027_stream_regress/log/027_stream_regress_primary.log 2026-05-11 14:09:34.397 CEST [4064132][walsender][40/0:0] LOG: released physical replication slot "standby_1" TRAP: failed Assert("!pgStatLocal.shmem->is_shutdown"), File: "../pgsql/src/backend/utils/activity/pgstat.c", Line: 612, PID: 4064132 postgres: primary: walsender bf [local] streaming 0/15B4FC98(ExceptionalCondition+0x5f) [0x45ae268] postgres: primary: walsender bf [local] streaming 0/15B4FC98(pgstat_report_stat+0x14d) [0x4492fe2] postgres: primary: walsender bf [local] streaming 0/15B4FC98(+0x49315c) [0x449315c] postgres: primary: walsender bf [local] streaming 0/15B4FC98(shmem_exit+0x78) [0x4448f00] postgres: primary: walsender bf [local] streaming 0/15B4FC98(+0x449020) [0x4449020] postgres: primary: walsender bf [local] streaming 0/15B4FC98(proc_exit+0x22) [0x44490c1] postgres: primary: walsender bf [local] streaming 0/15B4FC98(+0x3f5dbd) [0x43f5dbd] ... 2026-05-11 14:09:34.629 CEST [4063470][postmaster][:0] LOG:  server process (PID 4064132) was terminated by signal 6: Aborted 2026-05-11 14:09:34.629 CEST [4063470][postmaster][:0] DETAIL: Failed process was running: START_REPLICATION SLOT "standby_1" 0/3000000 TIMELINE 1 2026-05-11 14:09:34.631 CEST [4063470][postmaster][:0] LOG: terminating any other active server processes And perhaps (I can't find the full log now) one year ago [2]: 227/305 postgresql:recovery / recovery/027_stream_regress ERROR           3364.50s   exit status 1 [01:19:39.781](0.108s) not ok 9 - check contents of pg_stat_statements on regression database [01:19:39.781](0.000s) #   Failed test 'check contents of pg_stat_statements on regression database' #   at /home/bf/bf-build/skink/REL_17_STABLE/pgsql/src/test/recovery/t/027_stream_regress.pl line 173. [01:19:39.781](0.000s) #          got: 'CREATE|f # SELECT|t' #     expected: 'CREATE|t # DELETE|t # INSERT|t # SELECT|t # UPDATE|t' I've reproduced such failures with the above modification applied, just running: for i in {1..20}; do PROVE_TESTS="t/027*" make -s check -C src/test/recovery/ || break; done Reproduced on REL_17_STABLE and REL_16_STABLE (starting from dd8008e8e, which updated 027_stream_regress.pl). Not reproduced on REL_18_STABLE after 87a6690cc (coming from [3]). [1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=skink&dt=2026-05-11%2010%3A25%3A22 [2] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=skink&dt=2025-03-18%2023%3A39%3A44 [3] https://www.postgresql.org/message-id/yegnemsijlrhocsfgs7gs7irnczjgkom6fmk2a5u2b66pbvzwi%40ph2h3wppcvdy Best regards, Alexander --------------sND80aAPB7VNlvPmWXwSXhlc Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
Hello hackers,

16.10.2023 12:00, PG Bug reporting form wrote:
The following bug has been logged on the website:

Bug reference:      18158
Logged by:          Alexander Lakhin
Email address:      exclusion@gmail.com
PostgreSQL version: 16.0
Operating system:   Ubuntu 22.04
Description:        
...
With the following modification in pgstat_flush_pending_entries():
+if (nowait && (rand() % 10 == 0))
+        did_flush = false;
+else
+{
         did_flush = kind_info->flush_pending_cb(entry_ref, nowait);
+}

the issue reproduced easily:
make -s check -C src/test/recovery/ PROVE_TESTS="t/012_subtransactions.pl"
grep TRAP -r src/test/recovery/tmp_check/log

# +++ tap check in src/test/recovery +++
t/012_subtransactions.pl .. ok    
All tests successful.
Files=1, Tests=12,  3 wallclock secs ( 0.01 usr  0.00 sys +  0.19 cusr  0.27
csys =  0.47 CPU)
Result: PASS
src/test/recovery/tmp_check/log/012_subtransactions_primary.log:
TRAP: failed Assert("!pgStatLocal.shmem->is_shutdown"), File: "pgstat.c",
Line: 616, PID: 2410126

It looks like skink produced this failure yesterday [1]:
241/316 recovery - postgresql:recovery/027_stream_regress                               ERROR           4374.08s   exit status 1
...
stderr:
#   Failed test 'check contents of pg_stat_statements on regression database'
#   at /home/bf/bf-build/skink/REL_17_STABLE/pgsql/src/test/recovery/t/027_stream_regress.pl line 177.
#          got: 'CREATE|f
# SELECT|t'
#     expected: 'CREATE|t
# DELETE|t
# INSERT|t
# SELECT|t
# UPDATE|t'
# Looks like you failed 1 test of 9.

 pgsql.build/testrun/recovery/027_stream_regress/log/027_stream_regress_primary.log
 
2026-05-11 14:09:34.397 CEST [4064132][walsender][40/0:0] LOG:  released physical replication slot "standby_1"
TRAP: failed Assert("!pgStatLocal.shmem->is_shutdown"), File: "../pgsql/src/backend/utils/activity/pgstat.c", Line: 612, PID: 4064132
postgres: primary: walsender bf [local] streaming 0/15B4FC98(ExceptionalCondition+0x5f) [0x45ae268]
postgres: primary: walsender bf [local] streaming 0/15B4FC98(pgstat_report_stat+0x14d) [0x4492fe2]
postgres: primary: walsender bf [local] streaming 0/15B4FC98(+0x49315c) [0x449315c]
postgres: primary: walsender bf [local] streaming 0/15B4FC98(shmem_exit+0x78) [0x4448f00]
postgres: primary: walsender bf [local] streaming 0/15B4FC98(+0x449020) [0x4449020]
postgres: primary: walsender bf [local] streaming 0/15B4FC98(proc_exit+0x22) [0x44490c1]
postgres: primary: walsender bf [local] streaming 0/15B4FC98(+0x3f5dbd) [0x43f5dbd]
...
2026-05-11 14:09:34.629 CEST [4063470][postmaster][:0] LOG:  server process (PID 4064132) was terminated by signal 6: Aborted
2026-05-11 14:09:34.629 CEST [4063470][postmaster][:0] DETAIL:  Failed process was running: START_REPLICATION SLOT "standby_1" 0/3000000 TIMELINE 1
2026-05-11 14:09:34.631 CEST [4063470][postmaster][:0] LOG:  terminating any other active server processes

And perhaps (I can't find the full log now) one year ago [2]:
227/305 postgresql:recovery / recovery/027_stream_regress                               ERROR           3364.50s   exit status 1

[01:19:39.781](0.108s) not ok 9 - check contents of pg_stat_statements on regression database
[01:19:39.781](0.000s) #   Failed test 'check contents of pg_stat_statements on regression database'
#   at /home/bf/bf-build/skink/REL_17_STABLE/pgsql/src/test/recovery/t/027_stream_regress.pl line 173.
[01:19:39.781](0.000s) #          got: 'CREATE|f
# SELECT|t'
#     expected: 'CREATE|t
# DELETE|t
# INSERT|t
# SELECT|t
# UPDATE|t'

I've reproduced such failures with the above modification applied, just
running:
for i in {1..20}; do PROVE_TESTS="t/027*" make -s check -C src/test/recovery/ || break; done

Reproduced on REL_17_STABLE and REL_16_STABLE (starting from dd8008e8e,
which updated 027_stream_regress.pl).

Not reproduced on REL_18_STABLE after 87a6690cc (coming from [3]).

[1] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=skink&dt=2026-05-11%2010%3A25%3A22
[2] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=skink&dt=2025-03-18%2023%3A39%3A44
[3] https://www.postgresql.org/message-id/yegnemsijlrhocsfgs7gs7irnczjgkom6fmk2a5u2b66pbvzwi%40ph2h3wppcvdy

Best regards,
Alexander
--------------sND80aAPB7VNlvPmWXwSXhlc--