errmsg("expected end timeline %u but found timeline %u",
starttli, entry->tli));
- if (!XLogRecPtrIsInvalid(entry->begin))
- tl_beginptr = entry->begin;
+ /*
+ * If this timeline entry matches with the timeline on which the
+ * backup started, WAL needs to be checked from the start LSN of the
+ * backup. If this entry refers to a newer timeline, WAL needs to be
+ * checked since the beginning of this timeline, so use the LSN where
+ * the timeline began.
+ */
+ if (starttli == entry->tli)
+ tl_beginptr = startptr;
else
{
- tl_beginptr = startptr;
+ tl_beginptr = entry->begin;
/*
* If we reach a TLI that has no valid beginning LSN, there can't
* better have arrived at the expected starting TLI. If not,
* something's gone horribly wrong.
*/
- if (starttli != entry->tli)
+ if (XLogRecPtrIsInvalid(entry->begin))
ereport(ERROR,
errmsg("expected start timeline %u but found timeline %u",
starttli, entry->tli));
use File::Path qw(rmtree);
use PostgresNode;
use TestLib;
-use Test::More tests => 7;
+use Test::More tests => 9;
# Start up the server and take a backup.
my $primary = PostgresNode->new('primary');
[ 'pg_verifybackup', $backup_path ],
qr/WAL parsing failed for timeline 1/,
'corrupt WAL file causes failure');
+
+# Check that WAL-Ranges has correct values with a history file and
+# a timeline > 1. Rather than plugging in a new standby, do a
+# self-promotion of this node.
+$primary->stop;
+$primary->append_conf('standby.signal');
+$primary->start;
+$primary->promote;
+$primary->safe_psql('postgres', 'SELECT pg_switch_wal()');
+my $backup_path2 = $primary->backup_dir . '/test_tli';
+# The base backup run below does a checkpoint, that removes the first segment
+# of the current timeline.
+$primary->command_ok([ 'pg_basebackup', '-D', $backup_path2, '--no-sync' ],
+ "base backup 2 ok");
+command_ok(
+ [ 'pg_verifybackup', $backup_path2 ],
+ 'valid base backup with timeline > 1');