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

Commit726d891

Browse files
committed
[Issue#192] Handle 0 offset STOP LSN on master
1 parent3347226 commit726d891

File tree

3 files changed

+34
-15
lines changed

3 files changed

+34
-15
lines changed

‎src/backup.c‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,8 +1740,10 @@ pg_stop_backup(pgBackup *backup, PGconn *pg_startbackup_conn,
17401740

17411741
if (!XRecOffIsValid(stop_backup_lsn_tmp))
17421742
{
1743-
/* It is ok for replica to return STOP LSN with NullXRecOff */
1744-
if (backup->from_replica&&XRecOffIsNull(stop_backup_lsn_tmp))
1743+
/* It is ok for replica to return STOP LSN with NullXRecOff
1744+
* UPD: Apparently it is ok even for master.
1745+
*/
1746+
if (XRecOffIsNull(stop_backup_lsn_tmp))
17451747
{
17461748
char*xlog_path,
17471749
stream_xlog_path[MAXPGPATH];
@@ -1798,13 +1800,20 @@ pg_stop_backup(pgBackup *backup, PGconn *pg_startbackup_conn,
17981800

17991801
/* Get the first record in segment with current stop_lsn */
18001802
lsn_tmp=get_first_record_lsn(xlog_path,segno,backup->tli,
1801-
instance_config.xlog_seg_size);
1803+
instance_config.xlog_seg_size,
1804+
instance_config.archive_timeout);
18021805

18031806
/* Check that returned LSN is valid and greater than stop_lsn */
18041807
if (XLogRecPtrIsInvalid(lsn_tmp)||
18051808
!XRecOffIsValid(lsn_tmp)||
18061809
lsn_tmp<stop_backup_lsn_tmp)
18071810
{
1811+
/* Backup from master should error out here */
1812+
if (!backup->from_replica)
1813+
elog(ERROR,"Failed to get next WAL record after %X/%X",
1814+
(uint32) (stop_backup_lsn_tmp >>32),
1815+
(uint32) (stop_backup_lsn_tmp));
1816+
18081817
/* No luck, falling back to looking up for previous record */
18091818
elog(WARNING,"Failed to get next WAL record after %X/%X, "
18101819
"looking for previous WAL record",

‎src/parsexlog.c‎

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -631,13 +631,14 @@ wal_contains_lsn(const char *archivedir, XLogRecPtr target_lsn,
631631
*/
632632
XLogRecPtr
633633
get_first_record_lsn(constchar*archivedir,XLogSegNosegno,
634-
TimeLineIDtli,uint32wal_seg_size)
634+
TimeLineIDtli,uint32wal_seg_size,inttimeout)
635635
{
636636
XLogReaderState*xlogreader;
637-
XLogReaderDatareader_data;
638-
XLogRecPtrrecord=InvalidXLogRecPtr;
639-
XLogRecPtrstartpoint;
640-
charwal_segment[MAXFNAMELEN];
637+
XLogReaderDatareader_data;
638+
XLogRecPtrrecord=InvalidXLogRecPtr;
639+
XLogRecPtrstartpoint;
640+
charwal_segment[MAXFNAMELEN];
641+
intattempts=0;
641642

642643
if (segno <=1)
643644
elog(ERROR,"Invalid WAL segment number "UINT64_FORMAT,segno);
@@ -653,13 +654,22 @@ get_first_record_lsn(const char *archivedir, XLogSegNosegno,
653654
/* Set startpoint to 0 in segno */
654655
GetXLogRecPtr(segno,0,wal_seg_size,startpoint);
655656

656-
record=XLogFindNextRecord(xlogreader,startpoint);
657+
while (attempts <=timeout)
658+
{
659+
record=XLogFindNextRecord(xlogreader,startpoint);
657660

658-
if (XLogRecPtrIsInvalid(record))
659-
record=InvalidXLogRecPtr;
660-
else
661-
elog(LOG,"First record in WAL segment \"%s\": %X/%X",wal_segment,
662-
(uint32) (record >>32), (uint32) (record));
661+
if (XLogRecPtrIsInvalid(record))
662+
record=InvalidXLogRecPtr;
663+
else
664+
{
665+
elog(LOG,"First record in WAL segment \"%s\": %X/%X",wal_segment,
666+
(uint32) (record >>32), (uint32) (record));
667+
break;
668+
}
669+
670+
attempts++;
671+
sleep(1);
672+
}
663673

664674
/* cleanup */
665675
CleanupXLogPageRead(xlogreader);

‎src/pg_probackup.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ extern XLogRecPtr get_prior_record_lsn(const char *archivedir, XLogRecPtr start_
957957
boolseek_prev_segment,uint32seg_size);
958958

959959
externXLogRecPtrget_first_record_lsn(constchar*archivedir,XLogRecPtrstart_lsn,
960-
TimeLineIDtli,uint32wal_seg_size);
960+
TimeLineIDtli,uint32wal_seg_size,inttimeout);
961961

962962
/* in util.c */
963963
externTimeLineIDget_current_timeline(PGconn*conn);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp