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 1qe6G8-005jPR-WE for pgsql-bugs@arkaria.postgresql.org; Thu, 07 Sep 2023 04:04:49 +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 1qe6G7-00F0uL-2H for pgsql-bugs@arkaria.postgresql.org; Thu, 07 Sep 2023 04:04:46 +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 1qe6G6-00F0uB-OA for pgsql-bugs@lists.postgresql.org; Thu, 07 Sep 2023 04:04:46 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qe6G1-003XzL-KG for pgsql-bugs@lists.postgresql.org; Thu, 07 Sep 2023 04:04:45 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 6F6933200437; Thu, 7 Sep 2023 00:04:38 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 07 Sep 2023 00:04:38 -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=1694059477; x=1694145877; bh=S4 gwv4qUlxKorxSu83O2Z6jSNgLwYvtkKGxRbgt++No=; b=p1V+5Rl1GpuzJvOKTN Q4AR4m6KIkShjimb/yaGQSVJK0nwQXLz7w6zz5NC+dLEc8CesK+J+b3eHqV8aTdc cz1QPF8JKH7ElU+QF4DeGSkDWFoNL3mKRZH/iGd3MvIVM/pRevhHadnxreQClEjp 2iIQGR0bpMDUud3JE/bU5V4JCnqGPGZdQZw3CCyzkpoa6+76HjxBq/1MN51gI586 grM8oDRu52vOaw2jODRoRCH8hKXMzYmdcfCDa4w07FsrpLIkJzqPVrN0oyL94OpL CPpZgEjj8CNBbAnY1yD97NQKZfCLHL0hdChFD7hAKEfq0LI9FloJsCTzNLkqbL+D fmsw== 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=1694059477; x=1694145877; bh=S4gwv4qUlxKor xSu83O2Z6jSNgLwYvtkKGxRbgt++No=; b=mX2zpCc3xmLcKPC70INCiI72Bg//y kL5OVcS6RwlFeLzve4hh7dwQxMS4X7W9ya7o7G8+uxGR6YD20maCvH+LX6IvkpQC 726HcchxGOPlH0FPTGkKdG6cc0uEgRR533wWvsDesJOdZj5bfRJe2e5KpixbuVVd wuHC1WdkGDDEch2+0sqe6CzxGAUdYtsPDIP/Jmrdvn/1tpiaJh6AR7akXx0VLuhz NOdx5BBdWjSsBUahr/t2eq+dFcRtkbCYjlq9yJhpF7f56bAMiBaUDnDnVOVObZCI 6tTXbiYcOo/QpjtNXLeZP72DUM3EZ/+IBn+CuqHYEL+5b6jcrmlGPRm8w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudehgedgkedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredt tddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesph grqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeg geegfffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih ii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 7 Sep 2023 00:04:35 -0400 (EDT) Date: Thu, 7 Sep 2023 13:04:32 +0900 From: Michael Paquier To: "James Pang (chaolpan)" Cc: 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="cCPMyPPeb7YAb0+8" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --cCPMyPPeb7YAb0+8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Sep 07, 2023 at 01:35:00AM +0000, James Pang (chaolpan) wrote: > PGv14.8, OS RHEL8, no SSL enabled in this database, we have a > lot of client sessions who check it's ssl state by query, all > other sessions got done very quickly, but only 1 session hang > there in 100% cpu tens of hours, even pg_terminate_backend does > not make it stopped either. It looks like abnormal.=20 >=20 > select ssl from pg_stat_ssl where pid=3Dpg_backend_pid(); This is hard to act on without more details or even a reproducible and self-contained test case. Even a java script based on the JDBC driver would be OK for me, for example, if it helps digging into what you are seeing. > #0 ensure_record_cache_typmod_slot_exists (typmod=3D0) at typcache.c:1714 > #1 0x000000000091185b in assign_record_type_typmod (tupDesc=3D, tupDesc@entry=3D0x27bc738) at typcache.c:2001 > #2 0x000000000091df03 in internal_get_result_type (funcid=3D, call_expr=3D, rsinfo=3D, > resultTypeId=3D, resultTupleDesc=3D0x7ffc9dff8cd0) at = funcapi.c:393 > #3 0x000000000091e263 in get_expr_result_type (expr=3Dexpr@entry=3D0x279= 2798, resultTypeId=3DresultTypeId@entry=3D0x7ffc9dff8ccc, > resultTupleDesc=3DresultTupleDesc@entry=3D0x7ffc9dff8cd0) at funcapi.= c:230 > #4 0x00000000006a2fa5 in ExecInitFunctionScan (node=3Dnode@entry=3D0x273= afa8, estate=3Destate@entry=3D0x269e948, eflags=3Deflags@entry=3D16) at nod= eFunctionscan.c:370 > #5 0x000000000069084e in ExecInitNode (node=3Dnode@entry=3D0x273afa8, es= tate=3Destate@entry=3D0x269e948, eflags=3Deflags@entry=3D16) at execProcnod= e.c:255 > #6 0x000000000068a96d in InitPlan (eflags=3D16, queryDesc=3D0x273b2d8) a= t execMain.c:936 > #7 standard_ExecutorStart (queryDesc=3D0x273b2d8, eflags=3D16) at execMa= in.c:263 > #8 0x00007f67c2821d5d in pgss_ExecutorStart (queryDesc=3D0x273b2d8, efla= gs=3D) at pg_stat_statements.c:965 > #9 0x00000000007fc226 in PortalStart (portal=3Dportal@entry=3D0x26848b8,= params=3Dparams@entry=3D0x0, eflags=3Deflags@entry=3D0, snapshot=3Dsnapsho= t@entry=3D0x0) > at pquery.c:514 > #10 0x00000000007fa27f in exec_bind_message (input_message=3D0x7ffc9dff90= d0) at postgres.c:1995 > #11 PostgresMain (argc=3Dargc@entry=3D1, argv=3Dargv@entry=3D0x7ffc9dff93= 70, dbname=3D, username=3D) at postgres.c:4552 > #12 0x000000000077a4ea in BackendRun (port=3D, port=3D) at postmaster.c:4537 > #13 BackendStartup (port=3D) at postmaster.c:4259 > #14 ServerLoop () at postmaster.c:1745 > #15 0x000000000077b363 in PostmasterMain (argc=3Dargc@entry=3D5, argv=3Da= rgv@entry=3D0x256abc0) at postmaster.c:1417 > #16 0x00000000004fec63 in main (argc=3D5, argv=3D0x256abc0) at main.c:209 This stack is referring to a code path where we are checking that some of the type-related data associated to a record is around, but this does not say exactly where the loop happens, so... Are we looking on a loop in the function execution itself from which the information of pg_stat_ssl is retrieved (aka pg_stat_get_activity())? Or is the type cache somewhat broken because of the extended query protocol? That's not really possible to see any evidence based on the information provided, though it provides a few hits that can help. FWIW, I've not heard about an issue like that in the field. The first thing I would do is update to 14.9, which is the latest version of Postgres available for this major version. -- Michael --cCPMyPPeb7YAb0+8 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmT5S9AACgkQnvQgOdby QH13dg//X9jJ+23TKNZwpXl6un77LRSOY9pxgUDVViepAt7Tj2yWVMzG5c8bWstX 97QiaLPmPqkZ4eicW5S94WL36cvHN6Qsx9DVmMXyg6cP2HUZCKUjniid7+ZNFPOf dmpJD0iQEaTa9WSYul0hu8Xr2fjTy/BwT5zTp8i8drMR9JlhF0UKk02nKwirjR8O o2i7hw8Tvr2GUUp5YGaP/FefxNr55+wsbJjv4CCmr1/PdlY5kDPpG7hd1YsEG+OX bTHvm4cDdPO5uQNX4TBUjQfc6AN1YoyGZ+TlHacr5LOOKyVpU6C/XuKv6X7HGcpA Cz5EOFE36OAhPg+EI9nM8bjK15fV8rsoX6p5sF6snAYq/gjx+kj4eyeseRP9ORqo 3UoqJHqm+JTpexFUEXgXnMmztWWv1iugJY6Xi4VifrIaGsyJsZzZF8WDGv0sgrbs nkyMc2xnnHPbEtc4ATlHt0PdjDyNKpP9S2Z9VC+wVArC7ra9Xyy76E1d3S5WbLNi kxzzi95B0Tqvcr7vq17rfmtIIFtN/m+JmBlZk+exqI+5xYkcNM54TfE9nls7wGsE EDqD4m7eudQPmdsWfud1wtaPpttzvfxJ0+wOtjz8SK48KbVUZKj7n7cCTXx48exA njWbs7e8ExE5L/Vn0SVGnIz1msUgrqq7i31E91oHTnoO3KvdMvM= =sL6R -----END PGP SIGNATURE----- --cCPMyPPeb7YAb0+8--