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

Commit6271fce

Browse files
Add TIMELINE to backup_label file
Allows new test to confirm timelines matchAuthor: Michael PaquierReviewed-by: David Steele
1 parent6668a54 commit6271fce

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10535,6 +10535,7 @@ do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
1053510535
backup_started_in_recovery ?"standby" :"master");
1053610536
appendStringInfo(labelfile,"START TIME: %s\n",strfbuf);
1053710537
appendStringInfo(labelfile,"LABEL: %s\n",backupidstr);
10538+
appendStringInfo(labelfile,"START TIMELINE: %u\n",starttli);
1053810539

1053910540
/*
1054010541
* Okay, write the file, or return its contents to caller.
@@ -11015,9 +11016,13 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p)
1101511016
(uint32) (startpoint >>32), (uint32)startpoint,startxlogfilename);
1101611017
fprintf(fp,"STOP WAL LOCATION: %X/%X (file %s)\n",
1101711018
(uint32) (stoppoint >>32), (uint32)stoppoint,stopxlogfilename);
11018-
/* transfer remaining lines from label to history file */
11019+
/*
11020+
* Transfer remaining lines including label and start timeline to
11021+
* history file.
11022+
*/
1101911023
fprintf(fp,"%s",remaining);
1102011024
fprintf(fp,"STOP TIME: %s\n",strfbuf);
11025+
fprintf(fp,"STOP TIMELINE: %u\n",stoptli);
1102111026
if (fflush(fp)||ferror(fp)||FreeFile(fp))
1102211027
ereport(ERROR,
1102311028
(errcode_for_file_access(),
@@ -11228,11 +11233,13 @@ read_backup_label(XLogRecPtr *checkPointLoc, bool *backupEndRequired,
1122811233
bool*backupFromStandby)
1122911234
{
1123011235
charstartxlogfilename[MAXFNAMELEN];
11231-
TimeLineIDtli;
11236+
TimeLineIDtli_from_walseg,tli_from_file;
1123211237
FILE*lfp;
1123311238
charch;
1123411239
charbackuptype[20];
1123511240
charbackupfrom[20];
11241+
charbackuplabel[MAXPGPATH];
11242+
charbackuptime[128];
1123611243
uint32hi,
1123711244
lo;
1123811245

@@ -11259,7 +11266,7 @@ read_backup_label(XLogRecPtr *checkPointLoc, bool *backupEndRequired,
1125911266
* format).
1126011267
*/
1126111268
if (fscanf(lfp,"START WAL LOCATION: %X/%X (file %08X%16s)%c",
11262-
&hi,&lo,&tli,startxlogfilename,&ch)!=5||ch!='\n')
11269+
&hi,&lo,&tli_from_walseg,startxlogfilename,&ch)!=5||ch!='\n')
1126311270
ereport(FATAL,
1126411271
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1126511272
errmsg("invalid data in file \"%s\"",BACKUP_LABEL_FILE)));
@@ -11288,6 +11295,43 @@ read_backup_label(XLogRecPtr *checkPointLoc, bool *backupEndRequired,
1128811295
*backupFromStandby= true;
1128911296
}
1129011297

11298+
/*
11299+
* Parse START TIME and LABEL. Those are not mandatory fields for
11300+
* recovery but checking for their presence is useful for debugging
11301+
* and the next sanity checks. Cope also with the fact that the
11302+
* result buffers have a pre-allocated size, hence if the backup_label
11303+
* file has been generated with strings longer than the maximum assumed
11304+
* here an incorrect parsing happens. That's fine as only minor
11305+
* consistency checks are done afterwards.
11306+
*/
11307+
if (fscanf(lfp,"START TIME: %127[^\n]\n",backuptime)==1)
11308+
ereport(DEBUG1,
11309+
(errmsg("backup time %s in file \"%s\"",
11310+
backuptime,BACKUP_LABEL_FILE)));
11311+
11312+
if (fscanf(lfp,"LABEL: %1023[^\n]\n",backuplabel)==1)
11313+
ereport(DEBUG1,
11314+
(errmsg("backup label %s in file \"%s\"",
11315+
backuplabel,BACKUP_LABEL_FILE)));
11316+
11317+
/*
11318+
* START TIMELINE is new as of 11. Its parsing is not mandatory, still
11319+
* use it as a sanity check if present.
11320+
*/
11321+
if (fscanf(lfp,"START TIMELINE: %u\n",&tli_from_file)==1)
11322+
{
11323+
if (tli_from_walseg!=tli_from_file)
11324+
ereport(FATAL,
11325+
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
11326+
errmsg("invalid data in file \"%s\"",BACKUP_LABEL_FILE),
11327+
errdetail("Timeline ID parsed is %u, but expected %u",
11328+
tli_from_file,tli_from_walseg)));
11329+
11330+
ereport(DEBUG1,
11331+
(errmsg("backup timeline %u in file \"%s\"",
11332+
tli_from_file,BACKUP_LABEL_FILE)));
11333+
}
11334+
1129111335
if (ferror(lfp)||FreeFile(lfp))
1129211336
ereport(FATAL,
1129311337
(errcode_for_file_access(),

‎src/test/perl/PostgresNode.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ sub init
419419
print$conf"restart_after_crash = off\n";
420420
print$conf"log_line_prefix = '%m [%p]%q%a '\n";
421421
print$conf"log_statement = all\n";
422+
print$conf"log_min_messages = debug1\n";
422423
print$conf"log_replication_commands = on\n";
423424
print$conf"wal_retrieve_retry_interval = '500ms'\n";
424425
print$conf"port =$port\n";

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp