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 1oOWFZ-0000ap-U9 for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Aug 2022 03:31:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oOWFY-00081W-Hi for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Aug 2022 03:31:16 +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 1oOWFX-00081N-7V for pgsql-hackers@lists.postgresql.org; Thu, 18 Aug 2022 03:31:16 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oOWFP-0004hH-Hq for pgsql-hackers@lists.postgresql.org; Thu, 18 Aug 2022 03:31:12 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id D4BFA5C00B3; Wed, 17 Aug 2022 23:31:04 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 17 Aug 2022 23:31:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc: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=1660793464; x=1660879864; bh=Ws4xD0uNt1 fwTy8OtNdU0I1ye313N/GVEP+009CGIhg=; b=Rq/u0q5LlPHgnGDHBqq0ORQ1+s p2yr/pkFUoItQli0MNZ3S2srh6DTCmtpmu5CSwNZlDaBtrVFiyKHhi7naY612H0g vR/ZXJKW5aigCPlGXhIctVC8Gc0kDvL6kfPEdlCohCY7LQaZke6ud4OliDZfiwdI NJyXO4gpaqujwaGYMvTct0cbYpWNLCDf9+MaJ9QqbYJMV+U7NNy+PMlccPUfWu30 lf1nt6NMV7SHXpPVYEQMr19LzbzggxWQGAXG0VCROYxdTsMYNv0NLjruuo5wYqWw mOaBHJbKwoPZADtsvOqp3p7OivImY3PnzTcAom2peX7MRyLr9wzOHuqE+SUA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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=1660793464; x=1660879864; bh=Ws4xD0uNt1fwTy8OtNdU0I1ye313 N/GVEP+009CGIhg=; b=H57rLkdshKsJEbyqF8d7Fkm/jw05yA7UJqA8DYs4Zj2s jkCYvaYET1dOfVWBXzhq8+L+PY7pkCT0NVit9kX5PbC2iCXD1tZElfoeK9A7aVS0 cO7vPcx3o6rXxq6m6zzhNGS5hBAAQY/zygAauvhRv8WBdzmUF1WSZYAN4qUavFaP baZrqXT4ZxPsmF0+P2EqjZB0S7BPTijrSuI+JOswevpPsY+VJxxGEC3yZZfbZlu7 ga8Ubqx3BkrRuqzTydYAz4KC0KpO0HjourdocpmuXuMlGAqRvfFCgY9fy6y4Mh6S R10Ii0MUunEOTgozqS9pRUe4gtMoILSLNjT/06TKYg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdehjedgjeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredt tddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesph grqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeg geegfffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih ii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 17 Aug 2022 23:31:03 -0400 (EDT) Date: Thu, 18 Aug 2022 12:31:00 +0900 From: Michael Paquier To: Bharath Rupireddy Cc: Cary Huang , PostgreSQL Hackers Subject: Re: Add last failed connection error message to pg_stat_wal_receiver Message-ID: References: <165852348876.1168.5615622255167011778.pgcf@coridan.postgresql.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="fGndvSITvH4104LQ" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --fGndvSITvH4104LQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Aug 04, 2022 at 03:27:11PM +0530, Bharath Rupireddy wrote: > Good point. The walreceiver can exit for any reason. We can either 1) > store for all the error messages or 2) think of using sigsetjmp but > that only catches the ERROR kinds, leaving FATAL and PANIC messages. > The option (1) is simple but there are problems - we may miss storing > future error messages, good commenting and reviewing may help here and > all the error messages now need to be stored in string, which is > complex. The option (2) seems reasonable but we will miss FATAL and > PANIC messages (we have many ERRORs, 2 FATALs, 3 PANICs). Maybe a > combination of option (1) for FATALs and PANICs, and option (2) for > ERRORs helps. >=20 > Thoughts? PANIC is not something you'd care about as the system would go down as and shared memory would be reset (right?) even if restart_on_crash is enabled. Perhaps it would help here to use something like a macro to catch and save the error, in a style similar to what's in hba.c for example, which is the closest example I can think of, even if on ERROR we don't really care about the error string anyway as there is nothing to report back to the SQL views used for the HBA/ident files. FATAL may prove to be tricky though, because I'd expect the error to be saved in shared memory in this case. This is particularly critical as this takes the WAL receiver process down, actually. Anyway, outside the potential scope of the proposal, there are more things that I find strange with the code: - Why isn't the string reset when the WAL receiver is starting up? That surely is not OK to keep a past state not referring to what actually happens with a receiver currently running. - pg_stat_wal_receiver (system view) reports no rows if pid is NULL, which would be the state stored in shared memory after a connection. This means that one would never be able to see last_conn_error except when calling directly the SQL function pg_stat_get_wal_receiver(). One could say that we should report a row for this view all the time, but this creates a compatibility breakage: existing application assuming something like (one row <=3D> WAL receiver running) could break. -- Michael --fGndvSITvH4104LQ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmL9snQACgkQnvQgOdby QH09cw/9HGxc4NcwIRaVJ6Brgg/uqvEcCDxUwFOk9OyaM90ZebznZLYKbFzLjsiT rr5dj8xKCaQo8P92Qk6M+0p4gQM1/5XQBHUXeVs49gM1PNyi8my7qkWptmV5/CNo Izp3lbG1c4dPGEKdKrNTXAkqFf+1WqlStesVxDnkYdErZzdzMGByoClTGF4J2h2K k4pALEx7W3eIql0sI6k2RUEKWclpOcJ8mEZU1My2H9dvReS1MZVCz/WBW5enW2j9 T1pdLJpefdm1EdiPuez60O9IAw+woyXY/MZIvULF53XQlYm64kvd4iWPdj8Icv9x amk2A87yPfHcquTpbjiST5hQEqUO9V3hOe1c9jPmrzaQagF73CaHHEOkrUepGtkT pScolto93uHEKR0rBTTzRaU0ODAKZIqdZznaYjrFYPOxMAVdL3Fpx1eIrVJHjm6F 15dkYhDzTxhugCYjznKG54iXdIaPAlSsLAobCyaJ7AOp/WVKaRLgsRFStH6DvUWE CSBO68azTE6GbJLr2joLVFcv2KNTTTZjBINb2xpyoiPocDvodoH+MgXWOjj/RPFK LwOJ3WcGglCERo6uw8KeSYar+IMK9aQ2xZ4rS7QDa5pZeXmfWJc7PvXiFSihwyo0 LS+h7XfOe3wy6OoHKgLhsXkGWuZjHkVu5GPsG+hmOnKOn4d25h8= =0hGO -----END PGP SIGNATURE----- --fGndvSITvH4104LQ--