pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #19897: Recovery fails after "LOG: consistent recovery state reached"
5+ messages / 4 participants
[nested] [flat]
* BUG #19897: Recovery fails after "LOG: consistent recovery state reached"
@ 2026-11-12 15:08 PG Bug reporting form <noreply@postgresql.org>
2026-11-13 16:40 ` Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached" Srinath Reddy Sadipiralla <srinath2133@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: PG Bug reporting form @ 2026-11-12 15:08 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: harukat@sraoss.co.jp
The following bug has been logged on the website:
Bug reference: 19897
Logged by: Haruka Takatsuka
Email address: harukat@sraoss.co.jp
PostgreSQL version: 15.0
Operating system: Linux
Description:
When using the following procedure to recover a base backup taken from a
standby,
the service would sometimes fail to start up with log messages in the
following strange sequence:
LOG: consistent recovery state reached at ...
LOG: invalid record length at ...
FATAL: recovery ended before configured recovery target was reached
LOG: database system is ready to accept read-only connections
LOG: startup process (PID 1234) exited with exit code 1
The base backup had the same result after repeated attempts.
(recovery steps)
$ rm -f data/15.5reco/log/*
$ rm data/15.5reco/standby.signal
$ touch data/15.5reco/recovery.signal
$ cat >> data/15.5reco/postgresql.conf <<EOS
recovery_target = 'immediate'
restore_command = 'false' ## mimics not to be able to get valid wal and
history
recovery_target_action = 'pause'
EOS
$ pg_ctl start -D data/15.5reco
pg_ctl: could not start server
$ cat data/15.5/reco/log/*
2026-11-10 16:16:55.811 JST [3810] LOG: starting PostgreSQL 15.5 on
x86_64-pc-linux-gnu, compiled by gcc (GCC) 14.3.1 20250617 (Red Hat
14.3.1-2), 64-bit
2026-11-10 16:16:55.812 JST [3810] LOG: listening on IPv6 address "::1",
port 5434
2026-11-10 16:16:55.812 JST [3810] LOG: listening on IPv4 address
"127.0.0.1", port 5434
2026-11-10 16:16:55.817 JST [3810] LOG: listening on Unix socket
"/tmp/.s.PGSQL.5434"
2026-11-10 16:16:55.822 JST [3814] LOG: database system was interrupted
while in recovery at log time 2026-09-24 09:40:18 JST
2026-11-10 16:16:55.822 JST [3814] HINT: If this has occurred more than
once some data might be corrupted and you might need to choose an earlier
recovery target.
2026-11-10 16:16:56.448 JST [3814] LOG: starting point-in-time recovery to
earliest consistent point
2026-11-10 16:16:56.458 JST [3814] LOG: redo starts at 0/12000028
2026-11-10 16:16:56.963 JST [3814] LOG: consistent recovery state reached
at 0/1470A6B0
2026-11-10 16:16:56.963 JST [3814] LOG: invalid record length at
0/1470A6B0: wanted 24, got 0
2026-11-10 16:16:56.963 JST [3814] LOG: redo done at 0/1470A678 system
usage: CPU: user: 0.00 s, system: 0.40 s, elapsed: 0.50 s
2026-11-10 16:16:56.963 JST [3814] LOG: last completed transaction was at
log time 2026-09-24 09:42:16.241123+09
2026-11-10 16:16:56.963 JST [3814] FATAL: recovery ended before configured
recovery target was reached
2026-11-10 16:16:56.963 JST [3810] LOG: database system is ready to accept
read-only connections
2026-11-10 16:16:56.965 JST [3810] LOG: startup process (PID 3814) exited
with exit code 1
2026-11-10 16:16:56.965 JST [3810] LOG: terminating any other active server
processes
2026-11-10 16:16:56.965 JST [3810] LOG: shutting down due to startup
process failure
2026-11-10 16:16:56.967 JST [3810] LOG: database system is shut down
When I checked the source code, I found that recoveryStopsAfter() returned
false
at the condition "if (rmid != RM_XACT_ID) return false;" before reaching
the condition "if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE &&
reachedConsistency)".
After modifying the order of decisions as follows, I can now boot from the
same backup properly.
It looks like all PostgreSQL branches have the same problem.
diff --git a/src/backend/access/transam/xlogrecovery.c
b/src/backend/access/transam/xlogrecovery.c
index 52ac6d58423..796226efad4 100644
inline patch 1: src/backend/access/transam/xlogrecovery.c (+2/-0 lines) download inline-1.patch
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -2789,6 +2789,20 @@ recoveryStopsAfter(XLogReaderState *record)
return true;
}
+ /* Check if we should stop as soon as reaching consistency */
+ if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE &&
reachedConsistency)
+ {
+ ereport(LOG,
+ (errmsg("recovery stopping after reaching
consistency")));
+
+ recoveryStopAfter = true;
+ recoveryStopXid = InvalidTransactionId;
+ recoveryStopTime = 0;
+ recoveryStopLSN = InvalidXLogRecPtr;
+ recoveryStopName[0] = '\0';
+ return true;
+ }
+
if (rmid != RM_XACT_ID)
return false;
@@ -2867,20 +2881,6 @@ recoveryStopsAfter(XLogReaderState *record)
}
}
- /* Check if we should stop as soon as reaching consistency */
- if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE &&
reachedConsistency)
- {
- ereport(LOG,
- (errmsg("recovery stopping after reaching
consistency")));
-
- recoveryStopAfter = true;
- recoveryStopXid = InvalidTransactionId;
- recoveryStopTime = 0;
- recoveryStopLSN = InvalidXLogRecPtr;
- recoveryStopName[0] = '\0';
- return true;
- }
-
return false;
}
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached"
2026-11-12 15:08 BUG #19897: Recovery fails after "LOG: consistent recovery state reached" PG Bug reporting form <noreply@postgresql.org>
@ 2026-11-13 16:40 ` Srinath Reddy Sadipiralla <srinath2133@gmail.com>
2026-11-14 14:22 ` Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached" Zsolt Parragi <zsolt.parragi@percona.com>
0 siblings, 1 reply; 5+ messages in thread
From: Srinath Reddy Sadipiralla @ 2026-11-13 16:40 UTC (permalink / raw)
To: harukat@sraoss.co.jp; pgsql-bugs@lists.postgresql.org
Hi,
Thanks for the report and the analysis. I can reproduce this on master.
On Fri, Nov 13, 2026 at 2:27 PM PG Bug reporting form <
noreply@postgresql.org> wrote:
>
> diff --git a/src/backend/access/transam/xlogrecovery.c
> b/src/backend/access/transam/xlogrecovery.c
> index 52ac6d58423..796226efad4 100644
> --- a/src/backend/access/transam/xlogrecovery.c
> +++ b/src/backend/access/transam/xlogrecovery.c
> @@ -2789,6 +2789,20 @@ recoveryStopsAfter(XLogReaderState *record)
> return true;
> }
>
> + /* Check if we should stop as soon as reaching consistency */
> + if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE &&
> reachedConsistency)
> + {
> + ereport(LOG,
> + (errmsg("recovery stopping after reaching
> consistency")));
> +
> + recoveryStopAfter = true;
> + recoveryStopXid = InvalidTransactionId;
> + recoveryStopTime = 0;
> + recoveryStopLSN = InvalidXLogRecPtr;
> + recoveryStopName[0] = '\0';
> + return true;
> + }
> +
> if (rmid != RM_XACT_ID)
> return false;
>
> @@ -2867,20 +2881,6 @@ recoveryStopsAfter(XLogReaderState *record)
> }
> }
>
> - /* Check if we should stop as soon as reaching consistency */
> - if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE &&
> reachedConsistency)
> - {
> - ereport(LOG,
> - (errmsg("recovery stopping after reaching
> consistency")));
> -
> - recoveryStopAfter = true;
> - recoveryStopXid = InvalidTransactionId;
> - recoveryStopTime = 0;
> - recoveryStopLSN = InvalidXLogRecPtr;
> - recoveryStopName[0] = '\0';
> - return true;
> - }
> -
> return false;
> }
>
Your proposed fix of moving the check above the rmgr test does fix the
reported case. But if the record that makes us consistent is a commit
or abort, it now returns before the SetLatestXTime() call, so the "last
completed transaction" time and pg_last_xact_replay_timestamp() would
miss that transaction. The attached 0001 instead goes back to the
pre-4f1b890b137 structure: the rmgr test becomes part of the condition
for the transaction-record block, so the SetLatestXTime still happens and
the immediate check is reached for every record. If this patch makes sense
i will write a TAP test, thoughts?
--
Thanks :)
Srinath Reddy Sadipiralla
EDB: https://www.enterprisedb.com/
Attachments:
v1-0001-Fix-recovery_target-immediate-when-WAL-ends-at-th.patch (application/octet-stream, 2.0K) download
From 8a9e8f22f0d62cc6908f173500afb8adaf631147 Mon Sep 17 00:00:00 2001
From: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Date: Fri, 13 Nov 2026 21:23:26 +0530
Subject: [PATCH v1 1/1] Fix recovery_target = 'immediate' when WAL ends at the
consistency point
recoveryStopsAfter() returned early for anything that isn't a
transaction record, so for most records it never got to its check for
recovery_target = 'immediate'. Usually that doesn't matter, because
recoveryStopsBefore() then stops recovery at the next record. But when
there is no next record, as in a backup taken from a standby, recovery
runs off the end of the WAL and fails with "recovery ended before
configured recovery target was reached".
The early return came in with commit 4f1b890b137. Make the rmgr check
part of the condition again, as it was before that.
Reported-by: Haruka Takatsuka <harukat@sraoss.co.jp>
Discussion: https://postgr.es/m/19897-60cf65e39604f958@postgresql.org
---
src/backend/access/transam/xlogrecovery.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 52ac6d58423..3c828f13bce 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -2789,15 +2789,17 @@ recoveryStopsAfter(XLogReaderState *record)
return true;
}
- if (rmid != RM_XACT_ID)
- return false;
-
+ /*
+ * Don't return early for other record types: the immediate-target check
+ * at the bottom must be reached for every record.
+ */
xact_info = info & XLOG_XACT_OPMASK;
- if (xact_info == XLOG_XACT_COMMIT ||
- xact_info == XLOG_XACT_COMMIT_PREPARED ||
- xact_info == XLOG_XACT_ABORT ||
- xact_info == XLOG_XACT_ABORT_PREPARED)
+ if (rmid == RM_XACT_ID &&
+ (xact_info == XLOG_XACT_COMMIT ||
+ xact_info == XLOG_XACT_COMMIT_PREPARED ||
+ xact_info == XLOG_XACT_ABORT ||
+ xact_info == XLOG_XACT_ABORT_PREPARED))
{
TransactionId recordXid;
--
2.43.0
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached"
2026-11-12 15:08 BUG #19897: Recovery fails after "LOG: consistent recovery state reached" PG Bug reporting form <noreply@postgresql.org>
2026-11-13 16:40 ` Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached" Srinath Reddy Sadipiralla <srinath2133@gmail.com>
@ 2026-11-14 14:22 ` Zsolt Parragi <zsolt.parragi@percona.com>
2026-11-15 16:15 ` Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached" Zsolt Parragi <zsolt.parragi@percona.com>
0 siblings, 1 reply; 5+ messages in thread
From: Zsolt Parragi @ 2026-11-14 14:22 UTC (permalink / raw)
To: Srinath Reddy Sadipiralla <srinath2133@gmail.com>; +Cc: pgsql-bugs@lists.postgresql.org; harukat@sraoss.co.jp
Hello
I can also confirm the reported case, and also that the attached patch fixes it.
But I also found a few similar cases, that could be fixed together with it.
The first was pointed out by claude:
Take a data directory without backup_label after a crash (such as
pg_ctl stop -m immediate), create recovery.signal and set:
recovery_target = 'immediate'
restore_command = 'false'
recovery_target_action = 'pause'
And then even with 0001, we see:
LOG: starting point-in-time recovery to earliest consistent point
LOG: redo starts at 0/0175BA40
LOG: invalid record length at 0/0177B8B8: expected at least 24, got 0
LOG: consistent recovery state reached at 0/0177B8B8
LOG: redo done at 0/0177B720 ...
FATAL: recovery ended before configured recovery target was reached
This scenario is explicitly mentioned in InitWalRecovery ("Or if you
just kill a running primary server and put it into archive recovery by
creating a recovery signal file"), but doesn't work, even with 0001
applied. An alternative patch fixes this and the original report both:
adding a check right after the main redo loop, before the
recovery_target_action switch.
And then there's a third issue, if instead of immediate, we use fast
in the above repro, which again doesn't work. That needs some
additional changes, and to avoid code duplication, I also did some
refactorings around it.
Additionally, all the above was done on the primary, and we can do the
same tests on a standby, where things are different. One case (backup
on a standby + backup ending in a restore point) requires your fix
from v1, so I think even through the reported case is also fixed by my
version, we need both to cover everything.
Attached is a 2 part series, where 0001 is the same as before, while
0002 adds additional changes and test coverage. We need both patches
for all tests to pass.
Attachments: download all (2 files, .tar.gz)
v2-0001-Fix-recovery_target-immediate-when-WAL-ends-at-th.patch (text/x-patch, 2.0K) download
From 23eef7ed170c9766b49a40684390d7a2811064a7 Mon Sep 17 00:00:00 2001
From: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Date: Fri, 13 Nov 2026 21:23:26 +0530
Subject: [PATCH v3 1/2] Fix recovery_target = 'immediate' when WAL ends at the
consistency point
recoveryStopsAfter() returned early for anything that isn't a
transaction record, so for most records it never got to its check for
recovery_target = 'immediate'. Usually that doesn't matter, because
recoveryStopsBefore() then stops recovery at the next record. But when
there is no next record, as in a backup taken from a standby, recovery
runs off the end of the WAL and fails with "recovery ended before
configured recovery target was reached".
The early return came in with commit 4f1b890b137. Make the rmgr check
part of the condition again, as it was before that.
Reported-by: Haruka Takatsuka <harukat@sraoss.co.jp>
Discussion: https://postgr.es/m/19897-60cf65e39604f958@postgresql.org
---
src/backend/access/transam/xlogrecovery.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 52ac6d58423..3c828f13bce 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -2789,15 +2789,17 @@ recoveryStopsAfter(XLogReaderState *record)
return true;
}
- if (rmid != RM_XACT_ID)
- return false;
-
+ /*
+ * Don't return early for other record types: the immediate-target check
+ * at the bottom must be reached for every record.
+ */
xact_info = info & XLOG_XACT_OPMASK;
- if (xact_info == XLOG_XACT_COMMIT ||
- xact_info == XLOG_XACT_COMMIT_PREPARED ||
- xact_info == XLOG_XACT_ABORT ||
- xact_info == XLOG_XACT_ABORT_PREPARED)
+ if (rmid == RM_XACT_ID &&
+ (xact_info == XLOG_XACT_COMMIT ||
+ xact_info == XLOG_XACT_COMMIT_PREPARED ||
+ xact_info == XLOG_XACT_ABORT ||
+ xact_info == XLOG_XACT_ABORT_PREPARED))
{
TransactionId recordXid;
--
2.56.0
v2-0002-Fix-recovery_target-immediate-without-a-record-to.patch (text/x-patch, 11.3K) download
From 8eddf20eba352dc44de4ceee92c8c12e83eecc62 Mon Sep 17 00:00:00 2001
From: Zsolt Parragi <zsolt.parragi@percona.com>
Date: Sat, 14 Nov 2026 13:16:45 +0000
Subject: [PATCH v3 2/2] Fix recovery_target = 'immediate' without a record to
stop at
recovery_target = 'immediate' is only checked before and after replaying
a record. Consistency can also be reached where no record is replayed:
when a data directory without backup_label runs out of WAL in pg_wal, or
before redo even starts, after a clean shutdown or with a backup that
ends at its checkpoint record. If no more WAL was available, recovery
failed with "recovery ended before configured recovery target was
reached". In standby mode it waited for WAL that might never arrive.
Fix by not reading more WAL once consistency is reached in these places,
and by treating running out of WAL in a consistent state as reaching the
target. The path without any redo did not handle recovery targets, so
move applying recovery_target_action into a function both paths can call.
Discussion: https://postgr.es/m/19897-60cf65e39604f958%40postgresql.org
---
src/backend/access/transam/xlogrecovery.c | 124 +++++++++++++------
src/test/recovery/t/003_recovery_targets.pl | 125 ++++++++++++++++++++
2 files changed, 216 insertions(+), 33 deletions(-)
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 3c828f13bce..3063040b7c9 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -362,6 +362,8 @@ static void verifyBackupPageConsistency(XLogReaderState *record);
static bool recoveryStopsBefore(XLogReaderState *record);
static bool recoveryStopsAfter(XLogReaderState *record);
+static bool recoveryStopsAtEndOfWAL(void);
+static void recoveryTargetReached(void);
static char *getRecoveryStopReason(void);
static void recoveryPausesHere(bool endOfRecovery);
static bool recoveryApplyDelay(XLogReaderState *record);
@@ -1705,7 +1707,16 @@ PerformWalRecovery(void)
/* just have to read next record after CheckPoint */
Assert(xlogreader->ReadRecPtr == CheckPointLoc);
replayTLI = CheckPointTLI;
- record = ReadRecord(xlogprefetcher, LOG, false, replayTLI);
+
+ /*
+ * If consistency is all that was asked for and we are consistent
+ * already, don't look for more WAL. In standby mode we would wait
+ * for it forever.
+ */
+ if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE && reachedConsistency)
+ record = NULL;
+ else
+ record = ReadRecord(xlogprefetcher, LOG, false, replayTLI);
}
if (record != NULL)
@@ -1832,39 +1843,10 @@ PerformWalRecovery(void)
* end of main redo apply loop
*/
+ if (!reachedRecoveryTarget)
+ reachedRecoveryTarget = recoveryStopsAtEndOfWAL();
if (reachedRecoveryTarget)
- {
- if (!reachedConsistency)
- ereport(FATAL,
- (errmsg("requested recovery stop point is before consistent recovery point")));
-
- /*
- * This is the last point where we can restart recovery with a new
- * recovery target, if we shutdown and begin again. After this,
- * Resource Managers may choose to do permanent corrective actions
- * at end of recovery.
- */
- switch (recoveryTargetAction)
- {
- case RECOVERY_TARGET_ACTION_SHUTDOWN:
-
- /*
- * exit with special return code to request shutdown of
- * postmaster. Log messages issued from postmaster.
- */
- proc_exit(3);
-
- case RECOVERY_TARGET_ACTION_PAUSE:
- SetRecoveryPause(true);
- recoveryPausesHere(true);
-
- /* drop into promote */
- pg_fallthrough;
-
- case RECOVERY_TARGET_ACTION_PROMOTE:
- break;
- }
- }
+ recoveryTargetReached();
RmgrCleanup();
@@ -1885,6 +1867,10 @@ PerformWalRecovery(void)
/* there are no WAL records following the checkpoint */
ereport(LOG,
(errmsg("redo is not required")));
+
+ reachedRecoveryTarget = recoveryStopsAtEndOfWAL();
+ if (reachedRecoveryTarget)
+ recoveryTargetReached();
}
/*
@@ -1899,6 +1885,70 @@ PerformWalRecovery(void)
errmsg("recovery ended before configured recovery target was reached")));
}
+/*
+ * Subroutine of PerformWalRecovery, called when recovery ran out of WAL
+ * without stopping at the recovery target. Returns true if the target
+ * counts as reached anyway.
+ */
+static bool
+recoveryStopsAtEndOfWAL(void)
+{
+ if (!ArchiveRecoveryRequested)
+ return false;
+
+ /*
+ * Consistency can be reached by the last record, or only when running out
+ * of WAL, with no later record for recoveryStopsBefore() to stop at.
+ */
+ if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE && reachedConsistency)
+ {
+ ereport(LOG,
+ (errmsg("recovery stopping after reaching consistency")));
+ return true;
+ }
+
+ return false;
+}
+
+/*
+ * Subroutine of PerformWalRecovery, to apply recovery_target_action after
+ * the recovery target was reached.
+ */
+static void
+recoveryTargetReached(void)
+{
+ if (!reachedConsistency)
+ ereport(FATAL,
+ (errmsg("requested recovery stop point is before consistent recovery point")));
+
+ /*
+ * This is the last point where we can restart recovery with a new
+ * recovery target, if we shutdown and begin again. After this, Resource
+ * Managers may choose to do permanent corrective actions at end of
+ * recovery.
+ */
+ switch (recoveryTargetAction)
+ {
+ case RECOVERY_TARGET_ACTION_SHUTDOWN:
+
+ /*
+ * exit with special return code to request shutdown of
+ * postmaster. Log messages issued from postmaster.
+ */
+ proc_exit(3);
+
+ case RECOVERY_TARGET_ACTION_PAUSE:
+ SetRecoveryPause(true);
+ recoveryPausesHere(true);
+
+ /* drop into promote */
+ pg_fallthrough;
+
+ case RECOVERY_TARGET_ACTION_PROMOTE:
+ break;
+ }
+}
+
/*
* Subroutine of PerformWalRecovery, to apply one WAL record.
*/
@@ -3257,6 +3307,14 @@ ReadRecord(XLogPrefetcher *xlogprefetcher, int emode,
CheckRecoveryConsistency();
+ /*
+ * If consistency is all that was asked for, don't look for
+ * more WAL. In standby mode we would wait for it forever.
+ */
+ if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE &&
+ reachedConsistency)
+ return NULL;
+
/*
* Before we retry, reset lastSourceFailed and currentSource
* so that we will check the archive next.
diff --git a/src/test/recovery/t/003_recovery_targets.pl b/src/test/recovery/t/003_recovery_targets.pl
index db4a0ea74b2..90893ebba81 100644
--- a/src/test/recovery/t/003_recovery_targets.pl
+++ b/src/test/recovery/t/003_recovery_targets.pl
@@ -301,4 +301,129 @@ like(
qr/without epoch must be greater than or equal to 3/,
"invalid recovery_target_xid (lower bound check)");
+# recovery_target = 'immediate' has to work when WAL ends where consistency
+# is reached, with no later record to stop at. The restore_command set up
+# by enable_restoring() finds nothing, so recovery only has the WAL in
+# pg_wal. In standby mode there is nothing to stream from either, and
+# recovery must not wait for more WAL.
+sub test_immediate_at_end_of_wal
+{
+ my ($test_name, $node, $standby, $num_rows) = @_;
+
+ $test_name .= $standby ? ', standby mode' : ', archive recovery';
+
+ $node->enable_restoring($node, $standby);
+ $node->append_conf(
+ 'postgresql.conf', "recovery_target = 'immediate'
+recovery_target_action = 'promote'");
+ if (!$node->start(fail_ok => 1))
+ {
+ fail("recovery to immediate target: $test_name");
+ return;
+ }
+ if (!$node->poll_query_until(
+ 'postgres', "SELECT NOT pg_is_in_recovery()"))
+ {
+ fail("recovery to immediate target: $test_name");
+ return;
+ }
+
+ ok( $node->log_contains(
+ "recovery stopping after reaching consistency"),
+ "recovery to immediate target: $test_name");
+ is($node->safe_psql('postgres', "SELECT count(*) FROM tab_imm"),
+ $num_rows, "check contents after recovery: $test_name");
+ $node->stop;
+}
+
+# Data directory left by a crash, and by a clean shutdown. Consistency is
+# only reached when pg_wal runs out; after the clean shutdown there is no
+# record to replay at all.
+foreach my $stop_mode ('immediate', 'fast')
+{
+ foreach my $standby (0, 1)
+ {
+ my $node = PostgreSQL::Test::Cluster->new(
+ "immediate_stop_${stop_mode}_$standby");
+ $node->init(allows_streaming => 1);
+ $node->start;
+ $node->safe_psql('postgres',
+ "CREATE TABLE tab_imm AS SELECT generate_series(1, 10) AS a");
+ $node->stop($stop_mode);
+
+ test_immediate_at_end_of_wal("after $stop_mode shutdown",
+ $node, $standby, 10);
+ }
+}
+
+# Backups taken from a standby, with WAL ending at the backup end point.
+# The backup end point is the standby's minRecoveryPoint.
+my $node_imm_primary = PostgreSQL::Test::Cluster->new('immediate_primary');
+$node_imm_primary->init(allows_streaming => 1);
+$node_imm_primary->append_conf('postgresql.conf', 'autovacuum = off');
+$node_imm_primary->start;
+$node_imm_primary->backup('imm_backup');
+
+my $node_imm_standby = PostgreSQL::Test::Cluster->new('immediate_standby');
+$node_imm_standby->init_from_backup($node_imm_primary, 'imm_backup',
+ has_streaming => 1);
+$node_imm_standby->append_conf(
+ 'postgresql.conf', 'bgwriter_lru_maxpages = 0
+wal_retrieve_retry_interval = 100ms');
+$node_imm_standby->start;
+
+# First a backup without any WAL to replay: stop the primary to make its
+# shutdown checkpoint the last record, and have the standby do a
+# restartpoint at it.
+$node_imm_primary->safe_psql('postgres',
+ "CREATE TABLE tab_imm AS SELECT generate_series(1, 10) AS a");
+$node_imm_primary->stop;
+
+my ($stdout_ctl, $stderr_ctl) =
+ run_command([ 'pg_controldata', $node_imm_primary->data_dir ]);
+$stdout_ctl =~ /^Latest checkpoint location:\s*(\S+)$/m
+ or die "could not find checkpoint location in pg_controldata output";
+my $shutdown_lsn = $1;
+$node_imm_standby->poll_query_until('postgres',
+ "SELECT pg_last_wal_replay_lsn() > '$shutdown_lsn'::pg_lsn")
+ or die "Timed out while waiting for standby to replay shutdown checkpoint";
+$node_imm_standby->safe_psql('postgres', "CHECKPOINT");
+$node_imm_standby->backup('imm_backup_no_redo');
+
+# Then a backup where the last record is not a commit. The restartpoint
+# done for the backup sets minRecoveryPoint to the end of the replayed WAL,
+# as long as it has a page to flush that is newer than the old value. Kill
+# the primary before the backup, so that no more WAL can arrive.
+$node_imm_primary->start;
+$node_imm_primary->safe_psql(
+ 'postgres', qq{
+CHECKPOINT;
+INSERT INTO tab_imm VALUES (11);});
+
+# The restore point record is not flushed by its creation, wait for it
+# explicitly.
+my $imm_last_lsn = $node_imm_primary->safe_psql('postgres',
+ "SELECT pg_create_restore_point('imm_last_record')");
+$node_imm_primary->wait_for_catchup($node_imm_standby, 'replay',
+ $imm_last_lsn);
+$node_imm_primary->stop('immediate');
+$node_imm_standby->backup('imm_backup_redo');
+$node_imm_standby->stop;
+
+foreach my $standby (0, 1)
+{
+ my $node =
+ PostgreSQL::Test::Cluster->new("immediate_backup_no_redo_$standby");
+ $node->init_from_backup($node_imm_standby, 'imm_backup_no_redo');
+ unlink($node->data_dir . '/standby.signal');
+ test_immediate_at_end_of_wal('standby backup without redo',
+ $node, $standby, 10);
+
+ $node = PostgreSQL::Test::Cluster->new("immediate_backup_redo_$standby");
+ $node->init_from_backup($node_imm_standby, 'imm_backup_redo');
+ unlink($node->data_dir . '/standby.signal');
+ test_immediate_at_end_of_wal('standby backup ending in a restore point',
+ $node, $standby, 11);
+}
+
done_testing();
--
2.56.0
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached"
2026-11-12 15:08 BUG #19897: Recovery fails after "LOG: consistent recovery state reached" PG Bug reporting form <noreply@postgresql.org>
2026-11-13 16:40 ` Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached" Srinath Reddy Sadipiralla <srinath2133@gmail.com>
2026-11-14 14:22 ` Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached" Zsolt Parragi <zsolt.parragi@percona.com>
@ 2026-11-15 16:15 ` Zsolt Parragi <zsolt.parragi@percona.com>
2026-11-19 01:42 ` Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached" TAKATSUKA Haruka <harukat@sraoss.co.jp>
0 siblings, 1 reply; 5+ messages in thread
From: Zsolt Parragi @ 2026-11-15 16:15 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org
And after thinking about these changes, I realized that both of our
patches broke standby promotion: both resulted in cases where we
promoted the standby when we shouldn't have.
The attached v3 now doesn't modify the logic when we have a primary
connection set, and contains both patches in one file instead.
Attachments:
v3-0001-Fix-immediate-recovery-targets-at-end-of-WAL.patch (text/x-patch, 14.5K) download
From 374a957f4099f202f531b72fc25958b5a2bcd012 Mon Sep 17 00:00:00 2001
From: Zsolt Parragi <zsolt.parragi@percona.com>
Date: Sun, 15 Nov 2026 08:45:19 +0000
Subject: [PATCH v3] Fix immediate recovery targets at end of WAL
Recovery with recovery_target = 'immediate' could fail if consistency
was reached at the end of WAL. The target checks ran when reading or
replaying a record, so reaching consistency after the last record could
leave the target unrecognized. In standby mode, recovery could keep
waiting for more WAL instead.
Treat end of WAL as reaching the immediate target once recovery is
consistent, and apply recovery_target_action there. This also handles
recovery where no redo is needed. For standbys using only archive and
local WAL, allow recovery to finish at that point by ending the WAL
retry loop.
Author: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Author: Zsolt Parragi <zsolt.parragi@percona.com>
Reported-by: Haruka Takatsuka <harukat@sraoss.co.jp>
Discussion: https://postgr.es/m/19897-60cf65e39604f958%40postgresql.org
---
src/backend/access/transam/xlogrecovery.c | 138 ++++++++++----
src/test/recovery/t/003_recovery_targets.pl | 194 ++++++++++++++++++++
2 files changed, 299 insertions(+), 33 deletions(-)
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 52ac6d58423..9835f488c2d 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -362,6 +362,9 @@ static void verifyBackupPageConsistency(XLogReaderState *record);
static bool recoveryStopsBefore(XLogReaderState *record);
static bool recoveryStopsAfter(XLogReaderState *record);
+static bool recoveryStopsAtEndOfWAL(void);
+static bool immediateTargetNeedsNoMoreWAL(void);
+static void recoveryTargetReached(void);
static char *getRecoveryStopReason(void);
static void recoveryPausesHere(bool endOfRecovery);
static bool recoveryApplyDelay(XLogReaderState *record);
@@ -1832,39 +1835,10 @@ PerformWalRecovery(void)
* end of main redo apply loop
*/
+ if (!reachedRecoveryTarget)
+ reachedRecoveryTarget = recoveryStopsAtEndOfWAL();
if (reachedRecoveryTarget)
- {
- if (!reachedConsistency)
- ereport(FATAL,
- (errmsg("requested recovery stop point is before consistent recovery point")));
-
- /*
- * This is the last point where we can restart recovery with a new
- * recovery target, if we shutdown and begin again. After this,
- * Resource Managers may choose to do permanent corrective actions
- * at end of recovery.
- */
- switch (recoveryTargetAction)
- {
- case RECOVERY_TARGET_ACTION_SHUTDOWN:
-
- /*
- * exit with special return code to request shutdown of
- * postmaster. Log messages issued from postmaster.
- */
- proc_exit(3);
-
- case RECOVERY_TARGET_ACTION_PAUSE:
- SetRecoveryPause(true);
- recoveryPausesHere(true);
-
- /* drop into promote */
- pg_fallthrough;
-
- case RECOVERY_TARGET_ACTION_PROMOTE:
- break;
- }
- }
+ recoveryTargetReached();
RmgrCleanup();
@@ -1885,6 +1859,10 @@ PerformWalRecovery(void)
/* there are no WAL records following the checkpoint */
ereport(LOG,
(errmsg("redo is not required")));
+
+ reachedRecoveryTarget = recoveryStopsAtEndOfWAL();
+ if (reachedRecoveryTarget)
+ recoveryTargetReached();
}
/*
@@ -1899,6 +1877,92 @@ PerformWalRecovery(void)
errmsg("recovery ended before configured recovery target was reached")));
}
+/*
+ * Subroutine of PerformWalRecovery, called when recovery ran out of WAL
+ * without stopping at the recovery target. Returns true if the target
+ * counts as reached anyway.
+ */
+static bool
+recoveryStopsAtEndOfWAL(void)
+{
+ if (!ArchiveRecoveryRequested)
+ return false;
+
+ /*
+ * Consistency can be reached by the last record, or only when running out
+ * of WAL, with no later record for recoveryStopsBefore() to stop at.
+ */
+ if (recoveryTarget == RECOVERY_TARGET_IMMEDIATE && reachedConsistency)
+ {
+ ereport(LOG,
+ (errmsg("recovery stopping after reaching consistency")));
+ return true;
+ }
+
+ return false;
+}
+
+/*
+ * Can recovery stop when no more WAL is available? True if recovery_target
+ * = 'immediate' and consistency is reached.
+ *
+ * Not in standby mode with primary_conninfo set: keep waiting for streamed
+ * WAL then. Reading more is what starts the walreceiver, which fetches the
+ * upstream's timeline history files. Stopping without them could make us
+ * choose a timeline ID at promotion that is already used there.
+ */
+static bool
+immediateTargetNeedsNoMoreWAL(void)
+{
+ if (recoveryTarget != RECOVERY_TARGET_IMMEDIATE || !reachedConsistency)
+ return false;
+
+ if (StandbyModeRequested && PrimaryConnInfo &&
+ strcmp(PrimaryConnInfo, "") != 0)
+ return false;
+
+ return true;
+}
+
+/*
+ * Subroutine of PerformWalRecovery, to apply recovery_target_action after
+ * the recovery target was reached.
+ */
+static void
+recoveryTargetReached(void)
+{
+ if (!reachedConsistency)
+ ereport(FATAL,
+ (errmsg("requested recovery stop point is before consistent recovery point")));
+
+ /*
+ * This is the last point where we can restart recovery with a new
+ * recovery target, if we shutdown and begin again. After this, Resource
+ * Managers may choose to do permanent corrective actions at end of
+ * recovery.
+ */
+ switch (recoveryTargetAction)
+ {
+ case RECOVERY_TARGET_ACTION_SHUTDOWN:
+
+ /*
+ * exit with special return code to request shutdown of
+ * postmaster. Log messages issued from postmaster.
+ */
+ proc_exit(3);
+
+ case RECOVERY_TARGET_ACTION_PAUSE:
+ SetRecoveryPause(true);
+ recoveryPausesHere(true);
+
+ /* drop into promote */
+ pg_fallthrough;
+
+ case RECOVERY_TARGET_ACTION_PROMOTE:
+ break;
+ }
+}
+
/*
* Subroutine of PerformWalRecovery, to apply one WAL record.
*/
@@ -3266,7 +3330,8 @@ ReadRecord(XLogPrefetcher *xlogprefetcher, int emode,
}
/* In standby mode, loop back to retry. Otherwise, give up. */
- if (StandbyMode && !CheckForStandbyTrigger())
+ if (StandbyMode && !CheckForStandbyTrigger() &&
+ !immediateTargetNeedsNoMoreWAL())
continue;
else
return NULL;
@@ -3644,6 +3709,13 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
return XLREAD_FAIL;
}
+ /*
+ * Likewise if consistency is all that was asked for.
+ * Without a stream source we would retry forever.
+ */
+ if (StandbyMode && immediateTargetNeedsNoMoreWAL())
+ return XLREAD_FAIL;
+
/*
* Not in standby mode, and we've now tried the archive
* and pg_wal.
diff --git a/src/test/recovery/t/003_recovery_targets.pl b/src/test/recovery/t/003_recovery_targets.pl
index db4a0ea74b2..549f783c1f7 100644
--- a/src/test/recovery/t/003_recovery_targets.pl
+++ b/src/test/recovery/t/003_recovery_targets.pl
@@ -301,4 +301,198 @@ like(
qr/without epoch must be greater than or equal to 3/,
"invalid recovery_target_xid (lower bound check)");
+# recovery_target = 'immediate' has to work when WAL ends where consistency
+# is reached, with no later record to stop at. The restore_command set up
+# by enable_restoring() finds nothing, so recovery only has the WAL in
+# pg_wal. primary_conninfo is cleared, so in standby mode there is nothing
+# to stream from either, and recovery must not wait for more WAL.
+sub test_immediate_at_end_of_wal
+{
+ my ($test_name, $node, $standby, $num_rows) = @_;
+
+ $test_name .= $standby ? ', standby mode' : ', archive recovery';
+
+ $node->enable_restoring($node, $standby);
+ $node->append_conf(
+ 'postgresql.conf', "recovery_target = 'immediate'
+recovery_target_action = 'promote'
+primary_conninfo = ''");
+ if (!$node->start(fail_ok => 1))
+ {
+ fail("recovery to immediate target: $test_name");
+ return;
+ }
+ if (!$node->poll_query_until(
+ 'postgres', "SELECT NOT pg_is_in_recovery()"))
+ {
+ fail("recovery to immediate target: $test_name");
+ return;
+ }
+
+ ok( $node->log_contains(
+ "recovery stopping after reaching consistency"),
+ "recovery to immediate target: $test_name");
+ is($node->safe_psql('postgres', "SELECT count(*) FROM tab_imm"),
+ $num_rows, "check contents after recovery: $test_name");
+ $node->stop;
+}
+
+# Data directory left by a crash, and by a clean shutdown. Consistency is
+# only reached when pg_wal runs out; after the clean shutdown there is no
+# record to replay at all.
+foreach my $stop_mode ('immediate', 'fast')
+{
+ foreach my $standby (0, 1)
+ {
+ my $node = PostgreSQL::Test::Cluster->new(
+ "immediate_stop_${stop_mode}_$standby");
+ $node->init(allows_streaming => 1);
+ $node->start;
+ $node->safe_psql('postgres',
+ "CREATE TABLE tab_imm AS SELECT generate_series(1, 10) AS a");
+ $node->stop($stop_mode);
+
+ test_immediate_at_end_of_wal("after $stop_mode shutdown",
+ $node, $standby, 10);
+ }
+}
+
+# Backups taken from a standby, with WAL ending at the backup end point.
+# The backup end point is the standby's minRecoveryPoint.
+my $node_imm_primary = PostgreSQL::Test::Cluster->new('immediate_primary');
+$node_imm_primary->init(allows_streaming => 1);
+$node_imm_primary->append_conf('postgresql.conf', 'autovacuum = off');
+$node_imm_primary->start;
+$node_imm_primary->backup('imm_backup');
+
+my $node_imm_standby = PostgreSQL::Test::Cluster->new('immediate_standby');
+$node_imm_standby->init_from_backup($node_imm_primary, 'imm_backup',
+ has_streaming => 1);
+$node_imm_standby->append_conf(
+ 'postgresql.conf', 'bgwriter_lru_maxpages = 0
+wal_retrieve_retry_interval = 100ms');
+$node_imm_standby->start;
+
+# First a backup without any WAL to replay: stop the primary to make its
+# shutdown checkpoint the last record, and have the standby do a
+# restartpoint at it.
+$node_imm_primary->safe_psql('postgres',
+ "CREATE TABLE tab_imm AS SELECT generate_series(1, 10) AS a");
+$node_imm_primary->stop;
+
+my ($stdout_ctl, $stderr_ctl) =
+ run_command([ 'pg_controldata', $node_imm_primary->data_dir ]);
+$stdout_ctl =~ /^Latest checkpoint location:\s*(\S+)$/m
+ or die "could not find checkpoint location in pg_controldata output";
+my $shutdown_lsn = $1;
+$node_imm_standby->poll_query_until('postgres',
+ "SELECT pg_last_wal_replay_lsn() > '$shutdown_lsn'::pg_lsn")
+ or die "Timed out while waiting for standby to replay shutdown checkpoint";
+$node_imm_standby->safe_psql('postgres', "CHECKPOINT");
+$node_imm_standby->backup('imm_backup_no_redo');
+
+# Then a backup where the last record is not a commit. The restartpoint
+# done for the backup sets minRecoveryPoint to the end of the replayed WAL,
+# as long as it has a page to flush that is newer than the old value. Kill
+# the primary before the backup, so that no more WAL can arrive.
+$node_imm_primary->start;
+$node_imm_primary->safe_psql(
+ 'postgres', qq{
+CHECKPOINT;
+INSERT INTO tab_imm VALUES (11);});
+
+# The restore point record is not flushed by its creation, wait for it
+# explicitly.
+my $imm_last_lsn = $node_imm_primary->safe_psql('postgres',
+ "SELECT pg_create_restore_point('imm_last_record')");
+$node_imm_primary->wait_for_catchup($node_imm_standby, 'replay',
+ $imm_last_lsn);
+$node_imm_primary->stop('immediate');
+$node_imm_standby->backup('imm_backup_redo');
+$node_imm_standby->stop;
+
+foreach my $standby (0, 1)
+{
+ my $node =
+ PostgreSQL::Test::Cluster->new("immediate_backup_no_redo_$standby");
+ $node->init_from_backup($node_imm_standby, 'imm_backup_no_redo');
+ unlink($node->data_dir . '/standby.signal');
+ test_immediate_at_end_of_wal('standby backup without redo',
+ $node, $standby, 10);
+
+ $node = PostgreSQL::Test::Cluster->new("immediate_backup_redo_$standby");
+ $node->init_from_backup($node_imm_standby, 'imm_backup_redo');
+ unlink($node->data_dir . '/standby.signal');
+ test_immediate_at_end_of_wal('standby backup ending in a restore point',
+ $node, $standby, 11);
+}
+
+# The same backup in standby mode, streaming from its source standby after
+# that has been promoted. The backup has no history file for the new
+# timeline, only the walreceiver can fetch it, so recovery must not stop
+# before streaming.
+$node_imm_standby->start;
+$node_imm_standby->promote;
+$node_imm_standby->safe_psql('postgres', "INSERT INTO tab_imm VALUES (12)");
+
+my $node_imm_follow = PostgreSQL::Test::Cluster->new('immediate_follow');
+$node_imm_follow->init_from_backup($node_imm_standby, 'imm_backup_redo');
+$node_imm_follow->enable_streaming($node_imm_standby);
+$node_imm_follow->append_conf(
+ 'postgresql.conf', "recovery_target = 'immediate'
+recovery_target_action = 'promote'");
+$node_imm_follow->start;
+$node_imm_follow->poll_query_until('postgres',
+ "SELECT NOT pg_is_in_recovery()")
+ or die "Timed out while waiting for promotion";
+is( $node_imm_follow->safe_psql('postgres',
+ "SELECT timeline_id FROM pg_control_checkpoint()"),
+ 3,
+ "immediate target from standby backup with upstream on new timeline");
+is($node_imm_follow->safe_psql('postgres', "SELECT count(*) FROM tab_imm"),
+ 11, "check contents after recovery from standby backup with upstream");
+$node_imm_follow->stop;
+$node_imm_standby->stop;
+
+# With an upstream to stream from, recovery must not stop before the
+# walreceiver has fetched the upstream's timeline history files, or
+# promotion could select a timeline ID already in use there. Promote a
+# standby, then make the old primary follow it with an immediate target.
+foreach my $stop_mode ('fast', 'immediate')
+{
+ my $old_primary =
+ PostgreSQL::Test::Cluster->new("immediate_old_primary_$stop_mode");
+ $old_primary->init(allows_streaming => 1);
+ $old_primary->start;
+ $old_primary->safe_psql('postgres',
+ "CREATE TABLE tab_imm AS SELECT generate_series(1, 10) AS a");
+ $old_primary->backup('imm_tli_backup');
+
+ my $new_primary =
+ PostgreSQL::Test::Cluster->new("immediate_new_primary_$stop_mode");
+ $new_primary->init_from_backup($old_primary, 'imm_tli_backup',
+ has_streaming => 1);
+ $new_primary->start;
+ $old_primary->wait_for_catchup($new_primary);
+ $old_primary->stop($stop_mode);
+ $new_primary->promote;
+ $new_primary->safe_psql('postgres', "INSERT INTO tab_imm VALUES (11)");
+
+ $old_primary->enable_streaming($new_primary);
+ $old_primary->append_conf(
+ 'postgresql.conf', "recovery_target = 'immediate'
+recovery_target_action = 'promote'");
+ $old_primary->start;
+ $old_primary->poll_query_until('postgres',
+ "SELECT NOT pg_is_in_recovery()")
+ or die "Timed out while waiting for promotion";
+
+ is( $old_primary->safe_psql('postgres',
+ "SELECT timeline_id FROM pg_control_checkpoint()"),
+ 3,
+ "immediate target with upstream on new timeline, $stop_mode stop");
+ $old_primary->stop;
+ $new_primary->stop;
+}
+
done_testing();
--
2.56.0
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached"
2026-11-12 15:08 BUG #19897: Recovery fails after "LOG: consistent recovery state reached" PG Bug reporting form <noreply@postgresql.org>
2026-11-13 16:40 ` Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached" Srinath Reddy Sadipiralla <srinath2133@gmail.com>
2026-11-14 14:22 ` Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached" Zsolt Parragi <zsolt.parragi@percona.com>
2026-11-15 16:15 ` Re: BUG #19897: Recovery fails after "LOG: consistent recovery state reached" Zsolt Parragi <zsolt.parragi@percona.com>
@ 2026-11-19 01:42 ` TAKATSUKA Haruka <harukat@sraoss.co.jp>
0 siblings, 0 replies; 5+ messages in thread
From: TAKATSUKA Haruka @ 2026-11-19 01:42 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org
Thank you for creating the patch.
I applied the contents of this v3 patch to version 15.x
(with no special adjustments except for pg_fallthrough.)
I tested it on the pgdata where the issue was initially detected in 15.x
and confirmed that the problem has been resolved.
I also verified that the regular regression tests passed on 15.x.
But TAP test No.9 of 003_recovery_targets.pl which is commented as
"Check behavior when recovery ends before target is reached" is failed.
Is is expected "FATAL: recovery ended before configured recovery target was reached",
but after applying this patch the server now starts successfully.
+++ tap check in src/test/recovery +++
t/003_recovery_targets.pl .. 9/?
# Failed test 'recovery end before target reached is a fatal error'
# at t/003_recovery_targets.pl line 182.
t/003_recovery_targets.pl .. 29/? # Looks like you failed 1 test of 29.
t/003_recovery_targets.pl .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/29 subtests
Test Summary Report
-------------------
t/003_recovery_targets.pl (Wstat: 256 (exited 1) Tests: 29 Failed: 1)
Failed test: 9
Non-zero exit status: 1
Files=1, Tests=29, 202 wallclock secs ( 0.01 usr 0.01 sys + 2.01 cusr 3.90 csys = 5.93 CPU)
Result: FAIL
make: *** [Makefile:23: check] Error 1
$ tail tmp_check/log/003_recovery_targets_standby_8.log
2026-11-19 09:44:18.606 JST [6254] LOG: starting point-in-time recovery to "does_not_exist"
2026-11-19 09:44:18.609 JST [6254] LOG: restored log file "000000010000000000000003" from archive
2026-11-19 09:44:18.621 JST [6254] LOG: redo starts at 0/3000028
2026-11-19 09:44:18.625 JST [6254] LOG: restored log file "000000010000000000000004" from archive
2026-11-19 09:44:18.626 JST [6254] LOG: consistent recovery state reached at 0/3000100
2026-11-19 09:44:18.626 JST [6251] LOG: database system is ready to accept read-only connections
cp: cannot stat '/var/lib/pgsql/install/postgresql-15.5/src/test/recovery/tmp_check/t_003_recovery_targets_primary_data/archives/000000010000000000000005': No such file or directory
cp: cannot stat '/var/lib/pgsql/install/postgresql-15.5/src/test/recovery/tmp_check/t_003_recovery_targets_primary_data/archives/000000010000000000000005': No such file or directory
2026-11-19 09:44:18.635 JST [6254] LOG: pausing at the end of recovery
2026-11-19 09:44:18.635 JST [6254] HINT: Execute pg_wal_replay_resume() to promote.
I also tried on REL_15_STABLE head code and got same results.
with best regards,
Takatsuka Haruka / SRA OSS
On Sun, 15 Nov 2026 10:15:02 -0600
Zsolt Parragi <zsolt.parragi@percona.com> wrote:
> And after thinking about these changes, I realized that both of our
> patches broke standby promotion: both resulted in cases where we
> promoted the standby when we shouldn't have.
>
> The attached v3 now doesn't modify the logic when we have a primary
> connection set, and contains both patches in one file instead.
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2026-11-19 01:42 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-12 15:08 BUG #19897: Recovery fails after "LOG: consistent recovery state reached" PG Bug reporting form <noreply@postgresql.org>
2026-11-13 16:40 ` Srinath Reddy Sadipiralla <srinath2133@gmail.com>
2026-11-14 14:22 ` Zsolt Parragi <zsolt.parragi@percona.com>
2026-11-15 16:15 ` Zsolt Parragi <zsolt.parragi@percona.com>
2026-11-19 01:42 ` TAKATSUKA Haruka <harukat@sraoss.co.jp>
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