Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit29f9423

Browse files
committed
Fix backup manifests to generate correct WAL-Ranges across timelines
In a backup manifest, WAL-Ranges stores the range of WAL that isrequired for the backup to be valid. pg_verifybackup would theninternally use pg_waldump for the checks based on this data.When the timeline where the backup started was more than 1 with ahistory file looked at for the manifest data generation, the calculationof the WAL range for the first timeline to check was incorrect. Theprevious logic used as start LSN the start position of the firsttimeline, but it needs to use the start LSN of the backup. This wouldcause failures with pg_verifybackup, or any tools making use of thebackup manifests.This commit adds a test based on a logic using a self-promoted node,making it rather cheap.Author: Kyotaro HoriguchiDiscussion:https://postgr.es/m/20210818.143031.1867083699202617521.horikyota.ntt@gmail.comBackpatch-through: 13
1 parentb30f7f3 commit29f9423

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

‎src/backend/replication/backup_manifest.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,19 +236,26 @@ AddWALInfoToBackupManifest(backup_manifest_info *manifest, XLogRecPtr startptr,
236236
errmsg("expected end timeline %u but found timeline %u",
237237
starttli,entry->tli));
238238

239-
if (!XLogRecPtrIsInvalid(entry->begin))
240-
tl_beginptr=entry->begin;
239+
/*
240+
* If this timeline entry matches with the timeline on which the
241+
* backup started, WAL needs to be checked from the start LSN of the
242+
* backup. If this entry refers to a newer timeline, WAL needs to be
243+
* checked since the beginning of this timeline, so use the LSN where
244+
* the timeline began.
245+
*/
246+
if (starttli==entry->tli)
247+
tl_beginptr=startptr;
241248
else
242249
{
243-
tl_beginptr=startptr;
250+
tl_beginptr=entry->begin;
244251

245252
/*
246253
* If we reach a TLI that has no valid beginning LSN, there can't
247254
* be any more timelines in the history after this point, so we'd
248255
* better have arrived at the expected starting TLI. If not,
249256
* something's gone horribly wrong.
250257
*/
251-
if (starttli!=entry->tli)
258+
if (XLogRecPtrIsInvalid(entry->begin))
252259
ereport(ERROR,
253260
errmsg("expected start timeline %u but found timeline %u",
254261
starttli,entry->tli));

‎src/bin/pg_verifybackup/t/007_wal.pl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use File::Pathqw(rmtree);
88
use PostgresNode;
99
use TestLib;
10-
use Test::Moretests=>7;
10+
use Test::Moretests=>9;
1111

1212
# Start up the server and take a backup.
1313
my$master = get_new_node('master');
@@ -56,3 +56,20 @@
5656
['pg_verifybackup',$backup_path ],
5757
qr/WAL parsing failed for timeline 1/,
5858
'corrupt WAL file causes failure');
59+
60+
# Check that WAL-Ranges has correct values with a history file and
61+
# a timeline > 1. Rather than plugging in a new standby, do a
62+
# self-promotion of this node.
63+
$master->stop;
64+
$master->append_conf('standby.signal');
65+
$master->start;
66+
$master->promote;
67+
$master->safe_psql('postgres','SELECT pg_switch_wal()');
68+
my$backup_path2 =$master->backup_dir .'/test_tli';
69+
# The base backup run below does a checkpoint, that removes the first segment
70+
# of the current timeline.
71+
$master->command_ok(['pg_basebackup','-D',$backup_path2,'--no-sync' ],
72+
"base backup 2 ok");
73+
command_ok(
74+
['pg_verifybackup',$backup_path2 ],
75+
'valid base backup with timeline > 1');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp