Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iHtpD-0006f7-GG for pgsql-bugs@arkaria.postgresql.org; Tue, 08 Oct 2019 18:03:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iHtpC-0000fk-14 for pgsql-bugs@arkaria.postgresql.org; Tue, 08 Oct 2019 18:03:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iHtpB-0000fI-MS for pgsql-bugs@lists.postgresql.org; Tue, 08 Oct 2019 18:03:05 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1iHtp9-0003MK-0r for pgsql-bugs@lists.postgresql.org; Tue, 08 Oct 2019 18:03:04 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 6F59E5F7A0; Tue, 8 Oct 2019 14:03:02 -0400 (EDT) Date: Tue, 8 Oct 2019 14:03:02 -0400 From: Stephen Frost To: =?iso-8859-1?Q?Mart=EDn_Marqu=E9s?= Cc: pgsql-bugs@lists.postgresql.org, PostgreSQL-development Subject: Re: Non-null values of recovery functions after promote or crash of primary Message-ID: <20191008180302.GP6962@tamriel.snowman.net> References: <576b29e5-5edf-b4b7-bb73-7ffad63535e2@2ndquadrant.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="T5+skzg2xBROiZTk" Content-Disposition: inline In-Reply-To: <576b29e5-5edf-b4b7-bb73-7ffad63535e2@2ndquadrant.com> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --T5+skzg2xBROiZTk Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Mart=EDn Marqu=E9s (martin@2ndquadrant.com) wrote: > pg_last_wal_receive_lsn() > pg_last_wal_replay_lsn() > pg_last_xact_replay_timestamp() >=20 > Under normal circumstances we would expect to receive NULLs from all > three functions on a primary node, and code comments back up my thoughts. Agreed. > The problem is, what if the node is a standby which was promoted without > restarting, or that had to perform crash recovery? >=20 > So during the time it's recovering the values in ` XLogCtl` are updated > with recovery information, and once the recovery finishes, due to crash > recovery reaching a consistent state, or a promotion of a standby > happening, those values are not reset to startup defaults. >=20 > That's when you start seeing non-null values returned by > `pg_last_wal_replay_lsn()`and `pg_last_xact_replay_timestamp()`. >=20 > Now, I don't know if we should call this a bug, or an undocumented > anomaly. We could fix the bug by resetting the values from ` XLogCtl` > after finishing recovery, or document that we might see non-NULL values > in certain cases. IMV, and not unlike other similar cases I've talked about on another thread, these should be cleared when the system is promoted as they're otherwise confusing and nonsensical. Thanks, Stephen --T5+skzg2xBROiZTk Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJdnM9WAAoJEO1sijiDR2RV128P/279gBRskpbHhl8ZWtIP1rGs xqe7afXT/ZVsgvuYlee+KaL2jL5xTkwGZk+yE2qcS3TXTIXxamHFgIFUB89Bj8z6 rpiTs1rRkxj3gucF8uS5RLzVFpaFeaDFymGeCx4bbKLA+KBL7oM3ap6ArpQQOlKv MrtP8bk8MA0RGUCIvHmOprNOydNHJ5ptriza08xk0ZYDHFa9wArd0QjmCuZel2XD 8WBdNNec0K7wePxzS4gI8p8Q68vAvTMfPogM1lWMq23DswiuCAG/iI20WLZoZ2G/ JIVis8/SGx9tmvAMCiSC4a5XOf14JPglTZjXaRhjpKLLQ5/I6AfsanNftgAQXgU9 D7rpGyLjcNqCmyXvTi0ZhOxhsm2ivcp9JQETuVd5r3pr5PfDqJjVeAWXrrRf9q3g MBzjk7bL7Vq1M0Xf3lPc0kDLQ7TiRPMc6w9Mtd76V72Fj/G/pjHfj012jKDkURO7 h31qG780g+JEKjkFmxUFOfwMKubsC1xqyB8vYkyVTGt8k1g+IBCtIhaJk21hFc+I iatLuRarSU258KEfGNnaTW6O/ur616Yq40DZP76CTveF9R2yqqEhGtqjKhtntCqV /t5ap6dbiPsPGGh+obSQsmW5T+yFiYL4tesfaBLuPPHNlzFlOa94DrIdCpfx1MFK 4/QY3KBh23Orc28bmNT8 =PMLI -----END PGP SIGNATURE----- --T5+skzg2xBROiZTk--