From: Tom Lane <tgl@sss.pgh.pa.us>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: Torsten Förtsch <tfoertsch123@gmail.com>
Cc: pgsql-hackers@postgresql.org, Michael Paquier <michael@paquier.xyz>
Subject: Re: minor bug
Date: Wed, 18 Jan 2023 15:03:38 -0500
Message-ID: <3787515.1674072218@sss.pgh.pa.us> (raw)
In-Reply-To: <d0af6fef161cf9a161f2b9377193b9099e73d17e.camel@cybertec.at>
References: <CAKkG4_kUevPqbmyOfLajx7opAQk6Cvwkvx0HRcFjSPfRPTXanA@mail.gmail.com>
<b41b61c8ba52efa23d1079cc53c689713f5b1e0c.camel@cybertec.at>
<2964581.1673969570@sss.pgh.pa.us>
<d0af6fef161cf9a161f2b9377193b9099e73d17e.camel@cybertec.at>
Laurenz Albe <laurenz.albe@cybertec.at> 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
Attachments:0001-Don-t-show-bogus-recovery-stop-time.V3.patch (text/x-diff, 851B) downloaddiff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.cindex 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 = (recordXid == recoveryTargetXid);
}
- if (recoveryTarget == 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 know+ * this is a commit or abort record; but test its result anyway.+ */+ if (getRecordTimestamp(record, &recordXtime) &&+ recoveryTarget == RECOVERY_TARGET_TIME)
{
/*
* There can be many transactions that share the same commit time, so
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, laurenz.albe@cybertec.at, tfoertsch123@gmail.com, michael@paquier.xyz
Subject: Re: minor bug
In-Reply-To: <3787515.1674072218@sss.pgh.pa.us>
References: <CAKkG4_kUevPqbmyOfLajx7opAQk6Cvwkvx0HRcFjSPfRPTXanA@mail.gmail.com> <b41b61c8ba52efa23d1079cc53c689713f5b1e0c.camel@cybertec.at> <2964581.1673969570@sss.pgh.pa.us> <d0af6fef161cf9a161f2b9377193b9099e73d17e.camel@cybertec.at> <3787515.1674072218@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox