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

Commitc919c58

Browse files
author
Arthur Zakirov
committed
Wait previous segment for start_lsn
1 parenta5667d3 commitc919c58

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

‎src/backup.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static int checkpoint_timeout(void);
8585

8686
staticvoidadd_pgdata_files(parray*files,constchar*root);
8787
staticvoidwrite_backup_file_list(parray*files,constchar*root);
88-
staticvoidwait_wal_lsn(XLogRecPtrlsn);
88+
staticvoidwait_wal_lsn(XLogRecPtrlsn,boolwait_prev_segment);
8989
staticvoidwait_replica_wal_lsn(XLogRecPtrlsn,boolis_start_backup);
9090
staticvoidmake_pagemap_from_ptrack(parray*files);
9191
staticvoidStreamLog(void*arg);
@@ -645,7 +645,7 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
645645
* Because WAL streaming will start after pg_start_backup() in stream
646646
* mode.
647647
*/
648-
wait_wal_lsn(backup->start_lsn);
648+
wait_wal_lsn(backup->start_lsn, true);
649649

650650
/* Wait for start_lsn to be replayed by replica */
651651
if (from_replica)
@@ -814,9 +814,11 @@ pg_ptrack_get_and_clear(Oid tablespace_oid, Oid db_oid, Oid rel_oid,
814814
* archive 'wal' directory with WAL segment file.
815815
* If current backup started in stream mode wait for 'lsn' to be streamed in
816816
* 'pg_xlog' directory.
817+
*
818+
* If 'wait_prev_segment' wait for previous segment.
817819
*/
818820
staticvoid
819-
wait_wal_lsn(XLogRecPtrlsn)
821+
wait_wal_lsn(XLogRecPtrlsn,boolwait_prev_segment)
820822
{
821823
TimeLineIDtli;
822824
XLogSegNotargetSegNo;
@@ -830,6 +832,8 @@ wait_wal_lsn(XLogRecPtr lsn)
830832

831833
/* Compute the name of the WAL file containig requested LSN */
832834
XLByteToSeg(lsn,targetSegNo);
835+
if (wait_prev_segment)
836+
targetSegNo--;
833837
XLogFileName(wal_segment,tli,targetSegNo);
834838

835839
if (stream_wal)
@@ -1196,7 +1200,7 @@ pg_stop_backup(pgBackup *backup)
11961200
* Wait for stop_lsn to be archived or streamed.
11971201
* We wait for stop_lsn in stream mode just in case.
11981202
*/
1199-
wait_wal_lsn(stop_backup_lsn);
1203+
wait_wal_lsn(stop_backup_lsn, false);
12001204

12011205
if (stream_wal)
12021206
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp