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.94.2) (envelope-from ) id 1uyi1w-00BfGk-II for pgsql-committers@arkaria.postgresql.org; Wed, 17 Sep 2025 02:36:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uyi1t-0046LF-5K for pgsql-committers@arkaria.postgresql.org; Wed, 17 Sep 2025 02:36:21 +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.94.2) (envelope-from ) id 1uyi1s-0046L7-N6 for pgsql-committers@lists.postgresql.org; Wed, 17 Sep 2025 02:36:21 +0000 Received: from fout-b6-smtp.messagingengine.com ([202.12.124.149]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uyi1o-001EPE-32 for pgsql-committers@lists.postgresql.org; Wed, 17 Sep 2025 02:36:21 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.stl.internal (Postfix) with ESMTP id E50CC1D002B0; Tue, 16 Sep 2025 22:36:15 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Tue, 16 Sep 2025 22:36:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1758076575; x=1758162975; bh=feWy2wR09h yaoZau9D9CFdKyGLcPfvIfJWBLL2nrew4=; b=MLF5LLvZBSysilMvf8kfkNksov gyxQmY0Fn2m/G01EdPm9cercCjpP7k92VA1WXyeY2VPKyt4ITBVEjjA1dfUp6lHQ ej6T/bfTPKhdWBQ0dw8+WevnsVm0gOPP8LkAVieyLba6/injD61QM1ldsSfUoJ3K TS6tj+TsNUMPr+3aAOGmdrJ4zZdxctRSy9GSoz8lDDvtXB+bodhGy2D1uW+EyrWr LtZUF+AWL8Vm2T7AwGMaxpBv4U0YP17uYIrBFmeQTU8oFL4XQEbAPVknH+IQQwxj m/PSfYFXHfijH4n3VUo7bap4dZC09mxbh7lCg6kLBc+lhZ3yZF+21vVnBp/A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1758076575; x=1758162975; bh=feWy2wR09hyaoZau9D9CFdKyGLcPfvIfJWB LL2nrew4=; b=PYdJuMpKp2bG00vBoqmtSdGbxuNGcBf1O+ppC8RpwxGECh2iYSf DXXbmBzj6REAJkpaJAMNKXb5KuIv7X5zelLtY3uDKb9gS7QEfqlLqhMw2boIfrja l3R7zQYHuZNUeZzS98RSppN8KebTeOTvypCyqO0okUn6Nss+zYr+4d5I821wH+et fOHqoXRg14K4sAF8Q8Vgujn0Os8hLvvJ5w0zveUOg3brF0a39s2lGCNjl1Qw2t/6 6A7uqUehgXyAWHtwbJsQw3gkb3iZIZh6AX2JxQHMToqYbi4inpmSqv21f9NLuwk+ 7BxPownqTeBC/6wX8TzH6j1dTGRiDtxma1w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdegvddvjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdefhedmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvden ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeegffejvefgveduvdejtddvtdeijeeh udeuledvudeftdfgfeejvdekveekiedvvdenucffohhmrghinhepphhoshhtghhrvghsqh hlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhho mhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidpnhgspghrtghpthhtohepvddpmh houggvpehsmhhtphhouhhtpdhrtghpthhtohepnhgrthhhrghnsehpohhsthhgrhgvshhq lhdrohhrghdprhgtphhtthhopehpghhsqhhlqdgtohhmmhhithhtvghrsheslhhishhtsh drphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 16 Sep 2025 22:36:14 -0400 (EDT) Date: Wed, 17 Sep 2025 11:35:56 +0900 From: Michael Paquier To: Nathan Bossart Cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: Move named LWLock tranche requests to shared memory. Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="jwTCaz6znOgRFWEb" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --jwTCaz6znOgRFWEb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Ni Nathan, On Thu, Sep 11, 2025 at 09:15:12PM +0000, Nathan Bossart wrote: > Move named LWLock tranche requests to shared memory. >=20 > In EXEC_BACKEND builds, GetNamedLWLockTranche() can segfault when > called outside of the postmaster process, as it might access > NamedLWLockTrancheRequestArray, which won't be initialized. Given > the lack of reports, this is apparently unusual, presumably because > it is usually called from a shmem_startup_hook like this: Since this commit has been merged, batta has kept failing. Here is the first failure: https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=3Dbatta&dt=3D2025-0= 9-12%2002%3A05%3A01 I use this animal with a specific configuration: shared_preload_libraries =3D 'pg_stat_statements' compute_query_id =3D regress regress_dump_restore wal_consistency_checking --enable-injection-points The recovery tests 013_crash_restart.pl, 022_crash_temp_files.pl and 041_checkpoint_at_promote.pl stress some restart scenarios, not all use injection points. I could not get a backtrace from the host. However, I have come up with the following change in 013 that's able to reproduce what I think is the same crash: --- a/src/test/recovery/t/013_crash_restart.pl +++ b/src/test/recovery/t/013_crash_restart.pl @@ -21,6 +21,8 @@ my $psql_timeout =3D IPC::Run::timer($PostgreSQL::Test::U= tils::timeout_default); =20 my $node =3D PostgreSQL::Test::Cluster->new('primary'); $node->init(allows_streaming =3D> 1); +$node->append_conf('postgresql.conf', + "shared_preload_libraries =3D 'pg_stat_statements'"); $node->start(); =20 And here is the backtrace: #0 0x000055fcdf6bc97a in NumLWLocksForNamedTranches () at lwlock.c:385 385 numLocks +=3D NamedLWLockTrancheRequestArray[i].num_lwlocks; (gdb) bt #0 0x000055fcdf6bc97a in NumLWLocksForNamedTranches () at lwlock.c:385=20 #1 0x000055fcdf6bc9b3 in LWLockShmemSize () at lwlock.c:400=20 #2 0x000055fcdf65bda5 in CalculateShmemSize (num_semaphores=3D0x7ffcaf7a78= e4) at ipci.c:130=20 #3 0x000055fcdf65c0b1 in CreateSharedMemoryAndSemaphores () at ipci.c:210= =20 #4 0x000055fcdf42830c in PostmasterStateMachine () at postmaster.c:3223=20 #5 0x000055fcdf42703f in process_pm_child_exit () at postmaster.c:2558=20 #6 0x000055fcdf425729 in ServerLoop () at postmaster.c:1696=20 #7 0x000055fcdf424be1 in PostmasterMain (argc=3D4, argv=3D0x55fd0a8faa10) = at postmaster.c:1403=20 #8 0x000055fcdef80a19 in main (argc=3D4, argv=3D0x55fd0a8faa10) at main.c:= 231 (gdb) p i $3 =3D 0 (gdb) p NamedLWLockTrancheRequestArray[0] Cannot access memory at address 0x7f15ee4ccc08 Thanks, -- Michael --jwTCaz6znOgRFWEb Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmjKHowACgkQnvQgOdby QH1FcA//Wp7LdSBQMBgUW8WDH95l3YMWqC65KydpFGn9UMQfKzHbvgbKxalkOoOL uVZ4iQMxzq5lYJocvvtvUFFl3K8uhY8lTbQdCQUfU60d2T9HBCUA5BlMQwgvxXSV QtbygLvkEQ4oGAKi+V47edAklt78COCE76ohaYSzLQIYl7JGMtx4+3Ds6FosqAGh Y/9XbfLCfzTvTcQ0Vv7HI3NMBvknqFFBIX7wHbPq+ewHPIS9neVoxVhan8ua+aWT zWs+WYLLh9pVMlZpETB390DjUO9X0DW+XeVRRNgNyLA5KFZ+6rhv53VQik+BTd5B E+E5G5C196U+3l2zlIJe+1VpOSvFlxW4tDfYeRguToCFAGHM1y+i7EYrRM5oVwnh KCHtvfEYCAAVV+46xznbjHaydGZXpkQYcnbMpVLbaAkJXN7tN+FzSbwjseu92TP4 r+2QMiiTS8eKEzWvf4pmiwkmCii3FXY1EMBcac0luries+W3McH2TCW8w1qo4M/m +5Xd4wxrhIezEx6716UQMtNbWuIXxX+Nrjls+TWVAV28sy4Oqz5fqKeaAS33M3S2 N8/tafEyIZcf/PZ6kmLgYO1mPnTztFf8OH0fRzCxop2EQy7sNBzy8JcoNEtZSz2F aTROVTKVC3SlVgJGJLYx/ZZ751biYbHlePNzU+zMO4CB3Q1XEeo= =4KQQ -----END PGP SIGNATURE----- --jwTCaz6znOgRFWEb--