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 1wMxkM-000TWN-0i for pgsql-bugs@arkaria.postgresql.org; Wed, 13 May 2026 00:46:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wMxkI-006dVW-1Q for pgsql-bugs@arkaria.postgresql.org; Wed, 13 May 2026 00:46:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wMxkI-006dVN-0W for pgsql-bugs@lists.postgresql.org; Wed, 13 May 2026 00:46:42 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wMxkF-00000000JaV-3Tg1 for pgsql-bugs@lists.postgresql.org; Wed, 13 May 2026 00:46:42 +0000 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-6763cc8775cso12704783a12.0 for ; Tue, 12 May 2026 17:46:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1778633199; cv=none; d=google.com; s=arc-20240605; b=DWrPTT144BkBaqooetwA23Ev1n9dEmStaGm8JBBGWpv7kbfCEpSkDmEqSo/KmnFmQL bXP0f6CVUg0morwaiiLFYjbO5sVYAUoazUBi2iZG6k2D0GbDg6YlbUbYbsuwjicq04zX Ii4x4c9EJz3c1kq0KxO0TP0qHqZoxA1y2rMkF4JZhBgR2dVCMa+BeX0ip0odV0Tqp8zi K20cZOgE2VtUe0Y4BQ+XizuaOdL0FfBOeDm3lQYapBVGCu39WIiiqDl0oIN9ZdCmNLBC 9QqKYHVCFTYXGi8N58exDYSNIhFcff++IGc/ZC6rb8C8AY0qJ8O1bQ5B2dj3HoX+eYf5 mYZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ckhVPjjPsNgtyJVBoSweu3eH/D+dee0yp14oPt4b8LY=; fh=GidXX+j5YYQg2LlLcM1bKyho3OwuWqu9asWDUO64tgM=; b=Z/a/Z3f2T8qE3Tgc8tS8kD8d1dipNd9wCZli+gIYCcjSr/bMicG9VGg0GRQKt+1VXF +Sx/123vawRzx5MOirlI0jaAEmEyB0yM0gcflYehoy4hg8KKDHhkhHaWjSZLA7LHCjdM ASDXgNCWKrNjFNfIFoflWcckgfllaITIybLyfDYNPCRLqJlEQeLE9B5yV7z2ev07iUb4 JeWw4m0qy+PWTw+fXIK270OS7HU8Hkxm9f4HUSbVsXjncecGNqQsD8yiUXF9/MbkJ+Yn WdH0109vEW9peA0hC8gItPhA0QIgDApGokWh/ZtCwN6yomE1BmS3uBaIUaXxvFw60rC7 yCPA==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778633199; x=1779237999; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ckhVPjjPsNgtyJVBoSweu3eH/D+dee0yp14oPt4b8LY=; b=BUvfOLp8XfRJKyZqo+8sWO7WdKJkWGShC1jOMLUDMSWM1P9AlDvXFtlXf8hUVLT1Rq jwqqEszPfVPS45UdkyhrEqCW42uGIaBbe598v6bGg35NbnR5inulp/j5eD2kxggq/OCG 0yvGJA/4ywd68LCah1ieU8X/1nrHjETfEAz8dJPWlLe/xmKgfyVZLUwO/6NSjnlFOxIu HrGWVqUd6Wt03idKr2i4t7QfksFpXu7hy4bXiS92BfBuHrXC1yK6iqwDTeBt+JNmF6gB uOedrXFoNC+Gt6tYBfnDSx5HS8j+tUdQVepfG/2RNkDc5LGX+K8RE31+Jx44HJVwo7dj 3WhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778633199; x=1779237999; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ckhVPjjPsNgtyJVBoSweu3eH/D+dee0yp14oPt4b8LY=; b=dhMC6zpmesaxvY1WCH+w8aIhW7L58kDWfgGkuRf2X0kW7x0oSERFCgytaHiMTZED0J YF50tBuZEoUd5xsf/Och2lqjYsv1O6Gmcj1eOwkn6rQ63FgzAMGJj4eLWgYf4aT0/1p9 R0P+KxH6EitjaYSLHw4HGN77B5WXW9fkPzvTur94pVq7F0sTpMwoliqNPi5Bc40IxB4F KWECXYhoOjGVa3iNCW3YP0OzQQtbUBBks6yi+YB0OmeUD3iyB0BGhUFJB1OB+MKlDCC4 HYVt28/lu+de1AerSQF/4CHzVbiY+I/yD5hFcGxjurw6mYXvZVqJ8jZ8Lrf8CPtLIerz ecnw== X-Gm-Message-State: AOJu0YzHup6KQEkUmABcAJfnDdjxinZEw8hAiRUEEPTeFMGQPi2G8/5j ukl/xfoaNpYm1GlDGGMOi5oW9CU6HHeMmxq2+tIlqBLF0eOMemTZEajD3JFbfzWJiQhGfs0e6pG Z+FjwIgTkhdl1W6gLejaqzVLpyWQU6XY= X-Gm-Gg: Acq92OGd7hmvMad9g0zR4BkvRs16ThZisnw4jozX2ySBSCrnKV8FXvN1cj9l14bIyiy Nn/+nQZHY+IgQAN+zivE3G8w0K1bzi+RwyerBJI/MrfhaUda4YYej28275wzoFaBBEafk793M/O 1USCqO2GnE7V8O2jX852DhLBG5PBA4Q6lU84DKiGuGPvEqA/zmeZx+T6PP3vOQrnYaxq3AIGj/B fPFu8jCZPGpo6/Bkf7oP4DVsa6AdHzD2fXsEEbEeJD6Q/Dps1emW7Xxlbm6iVK5TqMUkhNwHEAS uf8G24IWzaxfcisA17YUEgUoT7NTtzTouGnDmgrTANPwNkeMhH92E3uMSJ684SyFMSa4c8KAv2M McrXc8Jw93NtowoX483mtdUELQyqvf46yurwGU3o= X-Received: by 2002:a17:907:86a4:b0:bcb:b757:a8a9 with SMTP id a640c23a62f3a-bd23ae18ef1mr365411866b.12.1778633198452; Tue, 12 May 2026 17:46:38 -0700 (PDT) MIME-Version: 1.0 References: <18158-88f667028dbc7e7b@postgresql.org> <58b5d6bf-7dca-41e5-8000-e12981205ada@gmail.com> In-Reply-To: <58b5d6bf-7dca-41e5-8000-e12981205ada@gmail.com> From: Xuneng Zhou Date: Wed, 13 May 2026 08:46:25 +0800 X-Gm-Features: AVHnY4JRkVGQP1We8bIuPmz9Qfl8JvOmQf1cP-peZ692nCXfryXgSwDPJLiPaYY Message-ID: Subject: Re: BUG #18158: Assert in pgstat_report_stat() fails when a backend shutting down with stats pending To: Alexander Lakhin Cc: pgsql-bugs@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Alexander, On Wed, May 13, 2026 at 4:00=E2=80=AFAM Alexander Lakhin wrote: > > 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 =3D=3D 0)) > + did_flush =3D false; > +else > +{ > did_flush =3D kind_info->flush_pending_cb(entry_ref, nowait); > +} > > the issue reproduced easily: > make -s check -C src/test/recovery/ PROVE_TESTS=3D"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=3D1, Tests=3D12, 3 wallclock secs ( 0.01 usr 0.00 sys + 0.19 cus= r 0.27 > csys =3D 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 datab= ase' > # at /home/bf/bf-build/skink/REL_17_STABLE/pgsql/src/test/recovery/t/02= 7_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_p= rimary.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/s= rc/backend/utils/activity/pgstat.c", Line: 612, PID: 4064132 > postgres: primary: walsender bf [local] streaming 0/15B4FC98(ExceptionalC= ondition+0x5f) [0x45ae268] > postgres: primary: walsender bf [local] streaming 0/15B4FC98(pgstat_repor= t_stat+0x14d) [0x4492fe2] > postgres: primary: walsender bf [local] streaming 0/15B4FC98(+0x49315c) [= 0x449315c] > postgres: primary: walsender bf [local] streaming 0/15B4FC98(shmem_exit+0= x78) [0x4448f00] > postgres: primary: walsender bf [local] streaming 0/15B4FC98(+0x449020) [= 0x4449020] > postgres: primary: walsender bf [local] streaming 0/15B4FC98(proc_exit+0x= 22) [0x44490c1] > postgres: primary: walsender bf [local] streaming 0/15B4FC98(+0x3f5dbd) [= 0x43f5dbd] > ... > 2026-05-11 14:09:34.629 CEST [4063470][postmaster][:0] LOG: server proce= ss (PID 4064132) was terminated by signal 6: Aborted > 2026-05-11 14:09:34.629 CEST [4063470][postmaster][:0] DETAIL: Failed pr= ocess 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_stateme= nts on regression database' > # at /home/bf/bf-build/skink/REL_17_STABLE/pgsql/src/test/recovery/t/02= 7_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=3D"t/027*" make -s check -C src/test/rec= overy/ || 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=3Dskink&dt=3D= 2026-05-11%2010%3A25%3A22 > [2] https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=3Dskink&dt=3D= 2025-03-18%2023%3A39%3A44 > [3] https://www.postgresql.org/message-id/yegnemsijlrhocsfgs7gs7irnczjgko= m6fmk2a5u2b66pbvzwi%40ph2h3wppcvdy > > Best regards, > Alexander Thanks for reporting this. It appears like backpatching an equivalent of 87a6690cc69 to REL_17/REL_16 would resolve this issue. -- Regards, Xuneng Zhou HighGo Software Co., Ltd.