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 1qeRbC-006ny9-OI for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Sep 2023 02:51:59 +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 1qeRbB-006HBX-LM for pgsql-bugs@arkaria.postgresql.org; Fri, 08 Sep 2023 02:51:57 +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.94.2) (envelope-from ) id 1qeRY1-006EW6-0D for pgsql-bugs@lists.postgresql.org; Fri, 08 Sep 2023 02:48:42 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qeRXw-003MF7-M9 for pgsql-bugs@lists.postgresql.org; Fri, 08 Sep 2023 02:48:39 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id A27115C0064; Thu, 7 Sep 2023 22:48:34 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 07 Sep 2023 22:48:34 -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=fm1; t=1694141314; x=1694227714; bh=+S ln81998yb/FNCUPP1fv/TfSgaJousABiH/A94khu8=; b=qUtvdv1FzwqoP6miti CKSrsGDODkyP5AE4AgHhiGA5f0RCfwnc3rXeQ2wVOuWSh1mVcUeW2icTWVt2aU6t n9GJjYf6Wg0nM7VbQ7li+qeep4IuXSDqYR0zRbv1Pfvo3xCtqDA88JYnucNA4Y+D b6afAbl7noh+oZI8HU/6eQiBvs+tAbT44vdDOGK0FrhPLr5zMwqw8tOs6NOws6TH F+okk38P2mje/SWPC8hktBook/KsF5Y2eUtx6KAhZo5VSx5AP0sOWw1hd4AYfLsL Ar21xJ4NvwjmMrGNlXr4FkjOyQf39ZAhcwCHKkXwta/t/i8JPD1rEAiZBejkJcjo KqUw== 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=fm1; t=1694141314; x=1694227714; bh=+Sln81998yb/F NCUPP1fv/TfSgaJousABiH/A94khu8=; b=x/UwIFbcRdJM2M7EgmMCOVNmdQpyP w/ZjlP0W7VmiLsznYWvIoFKdZRM+RoM8jwCNPvy4PmIZ75d5a3VBdvCZ+nHznDCI KYJx+U2VUrMEo1sgDI1GHzX5LZb7B4ELc6n4ks0TaVCs6QcpoeLpkZqUXTbtXpJi yp67UKcl8tCXvn7pkGFPXfvVfc7aOPzUMEd04kh5zWFiz+6kYcFLC7SPae2IVs3x wIeKGsvPis15skRhbkF2voLSVPGB7naHSg4d9BbXEJLaxLssHACZQlWBQSXUgiyU bicNB8GtLxGZeAB84XwRO01R3z54y3NHJZFaS2uoCkIHkJROeOZs4e3Pg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehiedgieegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredt tdejnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesph grqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepveetjefgjeevgedukeehieeu ieeuieevueeiudegheevuefggfduueelgeelieetnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih ii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 7 Sep 2023 22:48:32 -0400 (EDT) Date: Fri, 8 Sep 2023 11:48:28 +0900 From: Michael Paquier To: Thomas Munro Cc: "James Pang (chaolpan)" , PostgreSQL mailing lists Subject: Re: FW: query pg_stat_ssl hang 100%cpu Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="w7W4/WOwq1fWV1EX" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --w7W4/WOwq1fWV1EX Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Sep 7, 2023 at 10:39=E2=80=AFPM James Pang (chaolpan) wrote: > (gdb) p RecordCacheArray > $1 =3D (TupleDesc *) 0x7f5fac365d90 > (gdb) p RecordIdentifierArray > $2 =3D (uint64 *) 0x0 Oh, yeah, this stack is broken. You have been really unlucky to hit that. This can randomly cause any session to get stuck, and no need for the extended query protocol here. (I am not sure how, but my email server has somewhat not been able to get the previous messages from James. Anyway.) On Fri, Sep 08, 2023 at 11:45:51AM +1200, Thomas Munro wrote: > I think the lazy fix would be to re-order those allocations. A > marginally more elegant fix would be to merge the arrays, as in the > attached. Thoughts? So, ensure_record_cache_typmod_slot_exists() would allocate the initial RecordCacheArray and if it fails on the second one it keeps RecordCacheArrayLen at 0. When coming back again to this code path, the second part of the routine causes an infinite loop because the allocation has been done, but the tracked length is 0. Fun. This is broken since 4b93f57 where the second array has been introduced. Getting that fixed before 11 is EOL is nice as it was introduced there, so good timing. There is a repalloc_extended(), but I cannot get excited to use MCXT_ALLOC_NO_OOM in this code path if there is a simpler method to avoid this issue with a single allocation for the all information set. +static RecordCacheArrayEntry * RecordCacheArray =3D NULL;=20 pgindent is annoyed by that.. typedefs.list has been updated in your patch, so I guess that you missed one extra indentation after this is refreshed. Note that RememberToFreeTupleDescAtEOX() does something similar to the type cache, and it uses the same approach as your patch. +1 to your proposal of using a struct for the entries in the cache. -- Michael --w7W4/WOwq1fWV1EX Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmT6i3wACgkQnvQgOdby QH3fvg/7B5EXZAXSxQoEFVF81srCTnpF+tDt8qP298FH9U60YuLo9CqI7IDJNL1v cqrbyAd+DA5qHkkf68d8iUtNUPUmjCiN9780cU3Mq+oR5uFAk3tUPO+9pYw+uc/v nA9oIKmoMTIg8u6xc3UGCINdeRtQMLhfwyNTCR8k8zbIVjbbitSuiIHodoo49M9T DUp3q64T6SSjaMNEWkkyg7ZsEQ/IBnXjWTkYtImxOdE3bTOqx/ZsonUPigheZiJD mJo308qxzzOm3hJwWTXDucmFQPsd3y6URHJSa3s0Me0AFaT/y3nt0P23t44aCak8 yGHwZXWP80iEB6mRDuXQlSSHhzrPZD3VPRR2GQ7NvveElzarD/zVBfI+FOZI+g15 uFZRUbqGJpbDG6sJC0pVJTg08yVms5npVGdzztV+xZI8KWCuks3VZqNqj0H3sRId jg94PC5SkIi5HbbWEF74oIHzk8HMzMWnN4pAqIU4wu28TPdS4fuBdLVpZk2+XQq/ 60OkqFkeJb7BN6Qk15lUKBzqi50IBIuz2iEVvV26WNaEREb+S5x/wuZosQVKcQcX bcj7SlJRGiwGgZ8jUmtHckOot3sbDiz/p73bC0veSmnAxOMHaP9kzKCB4GpZ8rvi hpVqrUm2bVQbWq7DyXoz1P72fGfgvlv9sgcWeflk6d5SOX7gSXo= =zMn6 -----END PGP SIGNATURE----- --w7W4/WOwq1fWV1EX--