Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pvqYm-0000vR-7C for pgsql-general@arkaria.postgresql.org; Mon, 08 May 2023 02:25:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pvqYk-00036x-IO for pgsql-general@arkaria.postgresql.org; Mon, 08 May 2023 02:25:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pvqYi-00036l-VV for pgsql-general@lists.postgresql.org; Mon, 08 May 2023 02:25:06 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pvqYd-001HaQ-Sn for pgsql-general@postgresql.org; Mon, 08 May 2023 02:25:04 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 5E48B320027A; Sun, 7 May 2023 22:24:56 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sun, 07 May 2023 22:24:56 -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:sender :subject:subject:to:to; s=fm3; t=1683512695; x=1683599095; bh=to rzuVU5idYNedhh0aoq4hIstykOQk1CUs3PblFSSik=; b=tNhq43rcFnKCMP8qSh iqEXZy68aE0R26iQ5k8Jtpo4Y6R0zjYbdPG24eWkqLkustKf20spXKJEQFEeEWYn m6cOiA/naAq31QpmWuIAU+MHjsXEbumOlxUPRWDklabYuPqKuQcLauf3lsb+KA/s UttqEh6vwEltH+VeKYZYrERse/9scJ0Tuocof6iAr7FkAmMLm1ptoLkci0YGj1sk FDkcFvr5e7TCm3l2c9gWfD5D1CNV6MHE0yBY0ao0G9qhKJvQRgXMVpArCHnmPkSz ujEWmkcNcoKsiiYjMyDgNfrAND4HefHvQjpOL/iW1VXE4W87U1YHm9re5GwqPDX+ ow0w== 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:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1683512695; x=1683599095; bh=torzuVU5idYNe dhh0aoq4hIstykOQk1CUs3PblFSSik=; b=kM4Day6XacGByLJJwUqkJ13qwv192 vSkX7O0dpPULFNjMZfCRwbKrST1du0GyTpHl2Shl6rPT0rU/mqz+09zHdZpSZe5P /xt9FK+a051Vnds7CBSsbfvMD/aMO6nle+5zu/dJx14J+Me4QEg5yqOvkSLUiYYR ijoPXw6SpUm+YD8wtuhYCpbk4a3OxMTA/G35f9gKDVhV2GsExLnk0mCkXRJuGl1n 9Bdn3rDkK4L8otln8CSoBexOsMGuJlPbKx0Ald6WtXMmf6iJrqe/RcpoUdEQZsf8 rrTNpROkwtuC9mC/JYL6/apaG5hrvGuaFElzRFNB7YulA50S8GD66UfKg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefjedgieduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredt tddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesph grqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeg geegfffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih ii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 7 May 2023 22:24:53 -0400 (EDT) Date: Mon, 8 May 2023 11:24:48 +0900 From: Michael Paquier To: Thomas Munro Cc: Tom Lane , Evgeny Morozov , PostgreSQL General Subject: Re: "PANIC: could not open critical system index 2662" - twice Message-ID: References: <01020187e7f5a96c-9bd4497c-abff-4c91-8a3f-e751a1f7d4b4-000000@eu-west-1.amazonses.com> <01020187eae42315-1cc83aed-2b4f-4c9e-ae36-ee82778f7154-000000@eu-west-1.amazonses.com> <01020187f07f341f-d1593cf8-4fc7-4186-b70c-0c8862a2aa32-000000@eu-west-1.amazonses.com> <4029098.1683422490@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="48hjWCH6b8HoiuKO" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --48hjWCH6b8HoiuKO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, May 07, 2023 at 10:30:52PM +1200, Thomas Munro wrote: > Bug-in-PostgreSQL explanations could include that we forgot it was > dirty, or some backend wrote it out to the wrong file; but if we were > forgetting something like permanent or dirty, would there be a more > systematic failure? Oh, it could require special rare timing if it is > similar to 8a8661828's confusion about permanence level or otherwise > somehow not setting BM_PERMANENT, but in the target blocks, so I think > that'd require a checkpoint AND a crash. It doesn't reproduce for me, > but perhaps more unlucky ingredients are needed. >=20 > Bug-in-OS/FS explanations could include that a whole lot of writes > were mysteriously lost in some time window, so all those files still > contain the zeroes we write first in smgrextend(). I guess this > previously rare (previously limited to hash indexes?) use of sparse > file hole-punching could be a factor in an it's-all-ZFS's-fault > explanation: Yes, you would need a bit of all that. I can reproduce the same backtrace here. That's just my usual laptop with ext4, so this would be a Postgres bug. First, here are the four things running in parallel so as I can get a failure in loading a critical index when connecting: 1) Create and drop a database with WAL_LOG as strategy and the regression database as template: while true; do createdb --template=3Dregression --strategy=3Dwal_log testdb; dropdb testdb; done 2) Feeding more data to pg_class in the middle, while testing the connection to the database created: while true; do psql -c 'create table popo as select 1 as a;' regression > /dev/null 2= >&1 ; psql testdb -c "select 1" > /dev/null 2>&1 ; psql -c 'drop table popo' regression > /dev/null 2>&1 ; psql testdb -c "select 1" > /dev/null 2>&1 ; done; 3) Force some checkpoints: while true; do psql -c 'checkpoint' > /dev/null 2>&1; sleep 4; done 4) Force a few crashes and recoveries: while true ; do pg_ctl stop -m immediate ; pg_ctl start ; sleep 4 ; done And here is one backtrace: (gdb) bt #0 __pthread_kill_implementation (threadid=3D, signo=3Dsign= o@entry=3D6, no_tid=3Dno_tid@entry=3D0) at ./nptl/pthread_kill.c:44 #1 0x00007f8a395cad2f in __pthread_kill_internal (signo=3D6, threadid=3D) at ./nptl/pthread_kill.c:78 #2 0x00007f8a3957bef2 in __GI_raise (sig=3Dsig@entry=3D6) at ../sysdeps/po= six/raise.c:26 #3 0x00007f8a39566472 in __GI_abort () at ./stdlib/abort.c:79 #4 0x000055f0b36b95ac in errfinish (filename=3D0x55f0b38d4f68 "relcache.c"= , lineno=3D4335, funcname=3D0x55f0b38d6500 <__func__.12> "load_critical_ind= ex") at elog.c:604 #5 0x000055f0b36a9c64 in load_critical_index (indexoid=3D2662, heapoid=3D1= 259) at relcache.c:4335 #6 0x000055f0b36a9712 in RelationCacheInitializePhase3 () at relcache.c:41= 10 (gdb) up 5 #5 0x000055f0b36a9c64 in load_critical_index (indexoid=3D2662, heapoid=3D1= 259) at relcache.c:4335 4335 elog(PANIC, "could not open critical system index %u", indexoid); You can also get failures with btree deduplication because of the CTAS running above, by the way, but that's just the top of the iceberg once the state is corrupted: #0 __pthread_kill_implementation (threadid=3D, signo=3Dsign= o@entry=3D6, no_tid=3Dno_tid@entry=3D0) at ./nptl/pthread_kill.c:44 #1 0x00007fcae38abd2f in __pthread_kill_internal (signo=3D6, threadid=3D) at ./nptl/pthread_kill.c:78 #2 0x00007fcae385cef2 in __GI_raise (sig=3Dsig@entry=3D6) at ../sysdeps/po= six/raise.c:26 #3 0x00007fcae3847472 in __GI_abort () at ./stdlib/abort.c:79 #4 0x00005556a809f584 in ExceptionalCondition (conditionName=3D0x5556a812b= 639 "false", fileName=3D0x5556a812abc8 "heapam.c", lineNumber=3D7882) at as= sert.c:66 #5 0x00005556a79e13db in index_delete_sort_cmp (deltid1=3D0x5556a9682158, = deltid2=3D0x7ffdb62c7088) at heapam.c:7882 #6 0x00005556a79e14f6 in index_delete_sort (delstate=3D0x7ffdb62c8350) at = heapam.c:7923 #7 0x00005556a79e0cd0 in heap_index_delete_tuples (rel=3D0x7fcae0f1a9a8, d= elstate=3D0x7ffdb62c8350) at heapam.c:7580 #8 0x00005556a7a07be4 in table_index_delete_tuples (rel=3D0x7fcae0f1a9a8, = delstate=3D0x7ffdb62c8350) at ../../../../src/include/access/tableam.h:1337 #9 0x00005556a7a0a7a3 in _bt_delitems_delete_check (rel=3D0x7fcae0f231c8, = buf=3D179, heapRel=3D0x7fcae0f1a9a8, delstate=3D0x7ffdb62c8350) at nbtpage.= c:1541 #10 0x00005556a7a07545 in _bt_simpledel_pass (rel=3D0x7fcae0f231c8, buffer= =3D179, heapRel=3D0x7fcae0f1a9a8, deletable=3D0x7ffdb62c8430, ndeletable=3D= 160, newitem=3D0x5556a9689260,=20 Anyway, you would be able to see that b3e184a (pretty much the same as 15.2), without 8a86618 included. Once 8a86618 is included, all these steps are stable in the backend, at least here. Or do we have some low-hanging fruit with the WAL_LOG strategy? That could always be possible, of course, but that looks like the same issue to me, just with a different symptom showing up. -- Michael --48hjWCH6b8HoiuKO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmRYXXAACgkQnvQgOdby QH07aBAAqe/mj3C2ZeZDe9Z9K81JjWK2ghG52kEs2qkDZ3sk4FsqTc9Xu8M+EKJC ZZgz1xzHGAdlHhgZwMhG6eMM9/vNhvgB2z9ITmuE7d+W5lQLkgGcDq9i4m7RRZiK fxhoknp1r0Of4F6idKker5yn9ZR+cQRFAjTzbvZO82ngPckKRtLXMhsXVZBRxOpj s8dnXlTsCIo5kLmhpSt3wUCryXGGclv1Ua1sFOEs8WgycY68pk9BQr4BuRNwQtH5 2EBS4UXaNZ+y21cds8XAHQyrT1M3qz4CeWjEA8MQ7cMBK8ov61Qk7KWw6a+5jyNd W07Quh+hpYSDvg2dCW2IlbQI6rlNSMifBdJcDQ0UePspgpoC8AB7cNG/qOFpaJkE 7ozlBN4G41Vj2yUimIlejCVfmJj0Xc8Z3UqkIdSwsdZXkz0P+lFcoj+58oUbvzOT LJy0lzsRD/aFpwyDMDI6/uXvTyJHmQtLe8OzfWMaQmJ9RjWxnaLHxMD/XnOR5/FZ 6W2UqbDtuuqFAFL1MXVWpqQbfD/WmDizdAm/8hXUdPi1OzQhLPzg+1KmOZhdzmmL 9aITQtqVGHodx1/MLsVfduot6M0jCXOFx8lnwIriowZfxgCHUaNcgL4TfJT3i/eg XvNGq/0ZOtPM00rEbuOikk54S+HdRrzY8EHK7Thl95YieVvKNSM= =dkCL -----END PGP SIGNATURE----- --48hjWCH6b8HoiuKO--