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

Commiteca14e0

Browse files
committed
[Issue#261] PG13 support
1 parenta693fb5 commiteca14e0

File tree

2 files changed

+83
-30
lines changed

2 files changed

+83
-30
lines changed

‎src/backup.c‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -422,14 +422,13 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync, bool
422422
/* Extract information about files in backup_list parsing their names:*/
423423
parse_filelist_filenames(backup_files_list,instance_config.pgdata);
424424

425+
elog(LOG,"Current Start LSN: %X/%X, TLI: %X",
426+
(uint32) (current.start_lsn >>32), (uint32) (current.start_lsn),
427+
current.tli);
425428
if (current.backup_mode!=BACKUP_MODE_FULL)
426-
{
427-
elog(LOG,"Current tli: %X",current.tli);
428-
elog(LOG,"Parent start_lsn: %X/%X",
429-
(uint32) (prev_backup->start_lsn >>32), (uint32) (prev_backup->start_lsn));
430-
elog(LOG,"start_lsn: %X/%X",
431-
(uint32) (current.start_lsn >>32), (uint32) (current.start_lsn));
432-
}
429+
elog(LOG,"Parent Start LSN: %X/%X, TLI: %X",
430+
(uint32) (prev_backup->start_lsn >>32), (uint32) (prev_backup->start_lsn),
431+
prev_backup->tli);
433432

434433
/*
435434
* Build page mapping in incremental mode.

‎src/parsexlog.c‎

Lines changed: 77 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,12 @@ typedef struct
148148
intret;
149149
}xlog_thread_arg;
150150

151+
staticXLogRecord*WalReadRecord(XLogReaderState*xlogreader,XLogRecPtrstartpoint,char**errormsg);
152+
staticXLogReaderState*WalReaderAllocate(uint32wal_seg_size,XLogReaderData*reader_data);
153+
151154
staticintSimpleXLogPageRead(XLogReaderState*xlogreader,
152155
XLogRecPtrtargetPagePtr,
153-
intreqLen,XLogRecPtrtargetRecPtr,char*readBuf,
154-
TimeLineID*pageTLI);
156+
intreqLen,XLogRecPtrtargetRecPtr,char*readBuf);
155157
staticXLogReaderState*InitXLogPageRead(XLogReaderData*reader_data,
156158
constchar*archivedir,
157159
TimeLineIDtli,uint32segment_size,
@@ -551,7 +553,13 @@ read_recovery_info(const char *archivedir, TimeLineID tli, uint32 wal_seg_size,
551553
TimestampTzlast_time=0;
552554
char*errormsg;
553555

554-
record=XLogReadRecord(xlogreader,startpoint,&errormsg);
556+
#ifPG_VERSION_NUM >=130000
557+
if (XLogRecPtrIsInvalid(startpoint))
558+
startpoint=SizeOfXLogShortPHD;
559+
XLogBeginRead(xlogreader,startpoint);
560+
#endif
561+
562+
record=WalReadRecord(xlogreader,startpoint,&errormsg);
555563
if (record==NULL)
556564
{
557565
XLogRecPtrerrptr;
@@ -615,7 +623,13 @@ wal_contains_lsn(const char *archivedir, XLogRecPtr target_lsn,
615623

616624
xlogreader->system_identifier=instance_config.system_identifier;
617625

618-
res=XLogReadRecord(xlogreader,target_lsn,&errormsg)!=NULL;
626+
#ifPG_VERSION_NUM >=130000
627+
if (XLogRecPtrIsInvalid(target_lsn))
628+
target_lsn=SizeOfXLogShortPHD;
629+
XLogBeginRead(xlogreader,target_lsn);
630+
#endif
631+
632+
res=WalReadRecord(xlogreader,target_lsn,&errormsg)!=NULL;
619633
/* Didn't find 'target_lsn' and there is no error, return false */
620634

621635
if (errormsg)
@@ -656,6 +670,12 @@ get_first_record_lsn(const char *archivedir, XLogSegNosegno,
656670
/* Set startpoint to 0 in segno */
657671
GetXLogRecPtr(segno,0,wal_seg_size,startpoint);
658672

673+
#ifPG_VERSION_NUM >=130000
674+
if (XLogRecPtrIsInvalid(startpoint))
675+
startpoint=SizeOfXLogShortPHD;
676+
XLogBeginRead(xlogreader,startpoint);
677+
#endif
678+
659679
while (attempts <=timeout)
660680
{
661681
record=XLogFindNextRecord(xlogreader,startpoint);
@@ -710,6 +730,12 @@ get_next_record_lsn(const char *archivedir, XLogSegNosegno,
710730
/* Set startpoint to 0 in segno */
711731
GetXLogRecPtr(segno,0,wal_seg_size,startpoint);
712732

733+
#ifPG_VERSION_NUM >=130000
734+
if (XLogRecPtrIsInvalid(startpoint))
735+
startpoint=SizeOfXLogShortPHD;
736+
XLogBeginRead(xlogreader,startpoint);
737+
#endif
738+
713739
found=XLogFindNextRecord(xlogreader,startpoint);
714740

715741
if (XLogRecPtrIsInvalid(found))
@@ -733,7 +759,7 @@ get_next_record_lsn(const char *archivedir, XLogSegNosegno,
733759
if (interrupted)
734760
elog(ERROR,"Interrupted during WAL reading");
735761

736-
record=XLogReadRecord(xlogreader,startpoint,&errormsg);
762+
record=WalReadRecord(xlogreader,startpoint,&errormsg);
737763

738764
if (record==NULL)
739765
{
@@ -822,6 +848,13 @@ get_prior_record_lsn(const char *archivedir, XLogRecPtr start_lsn,
822848
XLogRecPtrfound;
823849

824850
GetXLogRecPtr(segno,0,wal_seg_size,startpoint);
851+
852+
#ifPG_VERSION_NUM >=130000
853+
if (XLogRecPtrIsInvalid(startpoint))
854+
startpoint=SizeOfXLogShortPHD;
855+
XLogBeginRead(xlogreader,startpoint);
856+
#endif
857+
825858
found=XLogFindNextRecord(xlogreader,startpoint);
826859

827860
if (XLogRecPtrIsInvalid(found))
@@ -846,7 +879,7 @@ get_prior_record_lsn(const char *archivedir, XLogRecPtr start_lsn,
846879
if (interrupted)
847880
elog(ERROR,"Interrupted during WAL reading");
848881

849-
record=XLogReadRecord(xlogreader,startpoint,&errormsg);
882+
record=WalReadRecord(xlogreader,startpoint,&errormsg);
850883
if (record==NULL)
851884
{
852885
XLogRecPtrerrptr;
@@ -905,8 +938,7 @@ get_gz_error(gzFile gzf)
905938
/* XLogreader callback function, to read a WAL page */
906939
staticint
907940
SimpleXLogPageRead(XLogReaderState*xlogreader,XLogRecPtrtargetPagePtr,
908-
intreqLen,XLogRecPtrtargetRecPtr,char*readBuf,
909-
TimeLineID*pageTLI)
941+
intreqLen,XLogRecPtrtargetRecPtr,char*readBuf)
910942
{
911943
XLogReaderData*reader_data;
912944
uint32targetPageOff;
@@ -1040,7 +1072,7 @@ SimpleXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr,
10401072
reader_data->prev_page_off==targetPageOff)
10411073
{
10421074
memcpy(readBuf,reader_data->page_buf,XLOG_BLCKSZ);
1043-
*pageTLI=reader_data->tli;
1075+
//*pageTLI = reader_data->tli;
10441076
returnXLOG_BLCKSZ;
10451077
}
10461078

@@ -1084,7 +1116,7 @@ SimpleXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr,
10841116

10851117
memcpy(reader_data->page_buf,readBuf,XLOG_BLCKSZ);
10861118
reader_data->prev_page_off=targetPageOff;
1087-
*pageTLI=reader_data->tli;
1119+
//*pageTLI = reader_data->tli;
10881120
returnXLOG_BLCKSZ;
10891121
}
10901122

@@ -1109,12 +1141,7 @@ InitXLogPageRead(XLogReaderData *reader_data, const char *archivedir,
11091141

11101142
if (allocate_reader)
11111143
{
1112-
#ifPG_VERSION_NUM >=110000
1113-
xlogreader=XLogReaderAllocate(wal_seg_size,&SimpleXLogPageRead,
1114-
reader_data);
1115-
#else
1116-
xlogreader=XLogReaderAllocate(&SimpleXLogPageRead,reader_data);
1117-
#endif
1144+
xlogreader=WalReaderAllocate(wal_seg_size,reader_data);
11181145
if (xlogreader==NULL)
11191146
elog(ERROR,"Out of memory");
11201147
xlogreader->system_identifier=instance_config.system_identifier;
@@ -1314,16 +1341,18 @@ XLogThreadWorker(void *arg)
13141341
uint32prev_page_off=0;
13151342
boolneed_read= true;
13161343

1317-
#ifPG_VERSION_NUM >=110000
1318-
xlogreader=XLogReaderAllocate(wal_seg_size,&SimpleXLogPageRead,
1319-
reader_data);
1320-
#else
1321-
xlogreader=XLogReaderAllocate(&SimpleXLogPageRead,reader_data);
1322-
#endif
1344+
xlogreader=WalReaderAllocate(wal_seg_size,reader_data);
1345+
13231346
if (xlogreader==NULL)
13241347
elog(ERROR,"Thread [%d]: out of memory",reader_data->thread_num);
13251348
xlogreader->system_identifier=instance_config.system_identifier;
13261349

1350+
#ifPG_VERSION_NUM >=130000
1351+
if (XLogRecPtrIsInvalid(thread_arg->startpoint))
1352+
thread_arg->startpoint=SizeOfXLogShortPHD;
1353+
XLogBeginRead(xlogreader,thread_arg->startpoint);
1354+
#endif
1355+
13271356
found=XLogFindNextRecord(xlogreader,thread_arg->startpoint);
13281357

13291358
/*
@@ -1376,7 +1405,7 @@ XLogThreadWorker(void *arg)
13761405
!SwitchThreadToNextWal(xlogreader,thread_arg))
13771406
break;
13781407

1379-
record=XLogReadRecord(xlogreader,thread_arg->startpoint,&errormsg);
1408+
record=WalReadRecord(xlogreader,thread_arg->startpoint,&errormsg);
13801409

13811410
if (record==NULL)
13821411
{
@@ -1857,3 +1886,28 @@ bool validate_wal_segment(TimeLineID tli, XLogSegNo segno, const char *prefetch_
18571886
returnrc;
18581887
}
18591888

1889+
staticXLogRecord*WalReadRecord(XLogReaderState*xlogreader,XLogRecPtrstartpoint,char**errormsg)
1890+
{
1891+
1892+
#ifPG_VERSION_NUM >=130000
1893+
returnXLogReadRecord(xlogreader,errormsg);
1894+
#else
1895+
returnXLogReadRecord(xlogreader,startpoint,errormsg);
1896+
#endif
1897+
1898+
}
1899+
1900+
staticXLogReaderState*WalReaderAllocate(uint32wal_seg_size,XLogReaderData*reader_data)
1901+
{
1902+
1903+
#ifPG_VERSION_NUM >=130000
1904+
returnXLogReaderAllocate(wal_seg_size,NULL,
1905+
XL_ROUTINE(.page_read=&SimpleXLogPageRead),
1906+
reader_data);
1907+
#elifPG_VERSION_NUM >=110000
1908+
returnXLogReaderAllocate(wal_seg_size,&SimpleXLogPageRead,
1909+
reader_data);
1910+
#else
1911+
returnXLogReaderAllocate(&SimpleXLogPageRead,reader_data);
1912+
#endif
1913+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp