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 1waMaD-001kOu-0F for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Jun 2026 23:55:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1waMaA-00E7MI-0k for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Jun 2026 23:55:38 +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 1waMa9-00E7M8-30 for pgsql-hackers@lists.postgresql.org; Thu, 18 Jun 2026 23:55:37 +0000 Received: from fhigh-a2-smtp.messagingengine.com ([103.168.172.153]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1waMa8-000000013SE-2ED7 for pgsql-hackers@postgresql.org; Thu, 18 Jun 2026 23:55:37 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.phl.internal (Postfix) with ESMTP id 8A8CA140014E; Thu, 18 Jun 2026 19:55:35 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Thu, 18 Jun 2026 19:55:35 -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=1781826935; x=1781913335; bh=uOXb6SU2i7 MExwYtPacqNat2gryjTPvB8E9buLzm/es=; b=XRogNf7JkZgezuISYlFg3l1uxy Ub5pY37f0AtI+FCTasu+erpBNCx7mlhAiMg06W9qpMygdn7o3/F7TEghL4mUnczz jTQMaEKXEWtJlkPEecXasPh2Ia58DfcCOZpuuLBvIa8fRkmmrMHI/pS62yj9ljNt JfNq5dJDBVfBF0J+LI/+bKxaN4m0p9d7UQ0Tfkahrh6dfMrEUFQWWr0l7nhqD9xG 6K7SVBveb63U794Or8V5OW6ZQAIf0xkSSKGTwA1ksYKEABMBrj5IrtokZ7w7XMKS lgxXJ+14czrnlgVvAQaVUR4FrRgtWPMQ47Sy7NnknFnTZNdQcGTr2e7HTEog== 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= 1781826935; x=1781913335; bh=uOXb6SU2i7MExwYtPacqNat2gryjTPvB8E9 buLzm/es=; b=T0p0u3zpFizUQIOzzGcIbJu5OvTvQw7goYEOukjvu1Z6edf1EYv imD5r2ehB4kB+Ju5MGLdtqRy4oOAK8gWZu3hMplfzBVIhT8uVfrYlRkbog49YdZ+ iOxeNq6EvjL/YtIRVqgMI5CB1DbIXFEJ0T8Zfw4vfgb6Mv3Nr421lgCpygrEnT3O +7Fba4YC9DUbbIFWL0BLord7srKQ5BYyimgOlTTo681+oFs36mJk8Bs1GK1IwvAU 7Z/PQITjh0x8RO2sO6A0Ggvw+vVMumw5xzAjbpms60eoo9cG9ioDIA7Dm82JBGST AM6iIDwF7+fw1f6z8sVgK1FaFqEQy4GqhsQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEtNXjnwXHLgVTtyxKZ9N76H5ss5WkrXJXzqfyw9ck2xVqdKLj6c58/xhPnHn6Jr2 y7Mh1z23ORtp1jO3mJB/rrqi+Sk0El/CTVh/k+B4soN3B1INihMVEAjNUCC6ku8xOc1Vxh Ma0OIvWeXB/rFvaW4giFGuzr/1jKqm4q/lf1FoKfZRhY4UfVbcJRgJlnnizNE/UXFnXQ9x 0ODiDMQ7ZE2hKYf/uoD3rrAGmtQd+KkqElQB+BuFadhHNBiaD9shldXTMb6eNJJ1E3OowE HxXUM0zd18xlJl+QMb6QkIsERkLmhuVvHmSWgbZd3/UK/4j9wOzMdRRWH8fDpHZOUw44Gt Yj6D+IcZ+CESD2yIN45rCyymG28OyQusjjue4wCMExZ7DrCUubiVVV3EQtnMmCvUl3M4JK LzoT025fIY8MbV+YOAsqbsGjimVMSg43u6c58lAopNpFz/DGilihbnsQttZmPNAE7Id+S7 plSST/5hW3uk6vfn2/q0jz8uu95+wk6IuDSbyKNKBFYyiDIyrK2vMj/ww3hP1cISAQCuGh HDpCUkVXibHij5TqBMNjKpCvYOqHBdVmjAVh6RPZ9GTdSyFhccMUNFhoU3b4jL6iOJHtWw k823fAaxv+RbCyCGC0A1lF0As1+WB8pW/PXmfH9TM40lnxfZx2Q915H0filQ X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 18 Jun 2026 19:55:34 -0400 (EDT) Date: Fri, 19 Jun 2026 08:55:30 +0900 From: Michael Paquier To: Matthias van de Meent Cc: Alexander Lakhin , pgsql-hackers Subject: Re: Unexpected behavior after OOM errors Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="LYbpxr1lupALNKib" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --LYbpxr1lupALNKib Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jun 18, 2026 at 11:27:28AM +0200, Matthias van de Meent wrote: > Each of the calls to > CacheRegisterSyscacheCallback/CacheRegisterRelcacheCallback can throw > an ERROR when all slots have been used. This would leave the typcache > in an invalid state, so I think that must be wrapped in a critical > section: neither syscache nor relcache has options to release > callbacks, and we can't safely continue without the callbacks > installed, so once an error is thrown here this backend can't ever be > properly initialized. This is unlike OOMs, whose conditions for > failure may (and often do) change as workloads change in other > backends. We don't ERROR when failing to register a syscache/relcache callback, we FATAL if we reach one of the thresholds. Reaching these thresholds points to me to a programming error anyway, so these should not matter in the field. The OOM is a random pattern that can happen outside the Postgres realm. Just in case, I have planted a elog(FATAL) triggering randomly in the middle of cache registration callback calls, and the typcache inconsistency does not come in play with the shutdown sequence once these trigger even if we have the tables set but not the callbacks. As a whole, I tend to think that reordering the actions is a solution good enough here. > I think Heikki's suggestion for a FATAL critical section option would > be a good alternative. It wouldn't always be sufficient, but would fix > issues here. That sounds like an interesting idea, potentially reusable for other areas, but I'm not really convinced that we need to add this kind of facility for the case dealt with here. To me, that's also where we could use a TRY/CATCH block and call it a day. If others feel differently about this matter, I'm fine to be outvoted. -- Michael --LYbpxr1lupALNKib Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmo0hXIACgkQnvQgOdby QH04NA/8DBV2TKG17nmIbFAolcgoP1Yb4KBWWVMSmgOaAON/qevfJFM9FgRGEy1s HS0ERnL3nXKez9ce9+fr+/GozXb+/54VwLebU3pg/bfBNRVJYspVQaUbC0FNg39T YqPw/QORrFpnw/+x1Uv/LJY2MXTdu0OcfHQEsLUfpLhz9NI05DhosCmRbFh3KeWl s5+Kv9wB8yaWlxMdSd+VLhVmT5UQK4pALWzblYMWLID6IzLXpW5zDpG7RXs8V6Va SRMt6UzqsciS9B5GdE8HMWPI837iDTV0eP8jMvKx5+bc1CkXmo802nt+Ck/FwDms 89Ifo1aAnf20EMlOrpPqfay3yKfzDm2ftbykV//GwyxGPCb1Ii7GLUMchsme8HH0 Fkix3Q4yHkibSf+9ZfBUE5sImkDBaT8gNssXiwGnz4054/E4BatoBcJ2rP4KKEu8 tKvWHN1UpaPhRLcpqVKD7fyfZetxZFK47umFru5W49eHr74DmAowcqmP4LRUwhUZ VSrFi5DNTn6a1DGEABSaWvS7YDx4PME25A2Nf4c26+oYfwLbZI8crx5Y5Kobvb0a ED+tL/rr0L4+k55EU3GFS0uBLyD9OzfGeg4n2KCa+J0oPujXuzCGY0ywRIfurF4/ 3XeO5vnYGJRll1oU+5XUq5qQFX11A+esKttqsaSmQz6JNhlkRcA= =h8Vd -----END PGP SIGNATURE----- --LYbpxr1lupALNKib--