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 1pIEey-0006Jy-Tm for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Jan 2023 20:03:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pIEex-0002qN-HT for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Jan 2023 20:03:47 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pIEex-0002qE-8T for pgsql-hackers@lists.postgresql.org; Wed, 18 Jan 2023 20:03:47 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pIEev-0002Q8-1D for pgsql-hackers@postgresql.org; Wed, 18 Jan 2023 20:03:46 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 30IK3cLf3787516; Wed, 18 Jan 2023 15:03:40 -0500 From: Tom Lane To: Laurenz Albe cc: Torsten =?ISO-8859-1?Q?F=F6rtsch?= , pgsql-hackers@postgresql.org, Michael Paquier Subject: Re: minor bug In-reply-to: References: <2964581.1673969570@sss.pgh.pa.us> Comments: In-reply-to Laurenz Albe message dated "Wed, 18 Jan 2023 09:27:02 +0100" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <3787480.1674072188.0@sss.pgh.pa.us> Date: Wed, 18 Jan 2023 15:03:38 -0500 Message-ID: <3787515.1674072218@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3787480.1674072188.1@sss.pgh.pa.us> Laurenz Albe writes: > On Tue, 2023-01-17 at 10:32 -0500, Tom Lane wrote: >> I seem to recall that the original idea was to report the timestamp >> of the commit/abort record we are stopping at. Maybe my memory is >> faulty, but I think that'd be significantly more useful than the >> current behavior, *especially* when the replay stopping point is >> defined by something other than time. >> (Also, the wording of the log message suggests that that's what >> the reported time is supposed to be. I wonder if somebody messed >> this up somewhere along the way.) > recoveryStopTime is set to recordXtime (the time of the xlog record) > a few lines above that patch, so this is useful information if it is > present. Ah, but that only happens if recoveryTarget == RECOVERY_TARGET_TIME. Digging in the git history, I see that this did use to work as I remember: we always extracted the record time before printing it. That was accidentally broken in refactoring in c945af80c. I think the correct fix is more like the attached. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="0001-Don-t-show-bogus-recovery-stop-time.V3.patch"; charset="us-ascii" Content-ID: <3787480.1674072188.2@sss.pgh.pa.us> Content-Description: 0001-Don-t-show-bogus-recovery-stop-time.V3.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/acces= s/transam/xlogrecovery.c index 5e65785306..c14d1f3ef6 100644 --- a/src/backend/access/transam/xlogrecovery.c +++ b/src/backend/access/transam/xlogrecovery.c @@ -2548,8 +2548,13 @@ recoveryStopsBefore(XLogReaderState *record) stopsHere =3D (recordXid =3D=3D recoveryTargetXid); } = - if (recoveryTarget =3D=3D RECOVERY_TARGET_TIME && - getRecordTimestamp(record, &recordXtime)) + /* + * Note: we must fetch recordXtime regardless of recoveryTarget setting. + * We don't expect getRecordTimestamp ever to fail, since we already kno= w + * this is a commit or abort record; but test its result anyway. + */ + if (getRecordTimestamp(record, &recordXtime) && + recoveryTarget =3D=3D RECOVERY_TARGET_TIME) { /* * There can be many transactions that share the same commit time, so ------- =_aaaaaaaaaa0--