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

Commit90897a5

Browse files
committed
Check segment file for start backup (testing archive_command).
1 parentb127345 commit90897a5

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

‎backup.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ static void create_file_list(parray *files,
8080
constchar*prefix,
8181
boolis_append);
8282
staticvoidwait_for_archive(PGconn*conn,pgBackup*backup,constchar*sql,boolstop_backup);
83+
staticvoidwait_archive_lsn(XLogRecPtrlsn,boollast_segno);
8384
staticvoidmake_pagemap_from_ptrack(parray*files);
8485
staticvoidStreamLog(void*arg);
8586

@@ -651,7 +652,12 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
651652
ERROR);
652653

653654
if (backup!=NULL)
655+
{
654656
get_lsn(start_stop_connect,res,&backup->start_lsn, false);
657+
if (!stream_wal&& !from_replica)
658+
wait_archive_lsn(backup->start_lsn, true);
659+
}
660+
655661
PQclear(res);
656662
}
657663

@@ -842,6 +848,42 @@ wait_for_archive(PGconn *conn, pgBackup *backup, const char *sql, bool stop_back
842848
elog(LOG,"%s() .ready deleted in %d try",__FUNCTION__,try_count);
843849
}
844850

851+
staticvoid
852+
wait_archive_lsn(XLogRecPtrlsn,boollast_segno)
853+
{
854+
TimeLineIDtli;
855+
XLogSegNotargetSegNo;
856+
charready_path[MAXPGPATH];
857+
charfile_name[MAXFNAMELEN];
858+
inttry_count;
859+
860+
tli=get_current_timeline(false);
861+
862+
/* As well as WAL file name */
863+
XLByteToSeg(lsn,targetSegNo);
864+
if (last_segno)
865+
targetSegNo--;
866+
XLogFileName(file_name,tli,targetSegNo);
867+
868+
snprintf(ready_path,lengthof(ready_path),
869+
"%s/%s",arclog_path,file_name);
870+
elog(LOG,"%s() wait for lsn:%li %s",__FUNCTION__,lsn,ready_path);
871+
/* wait until switched WAL is archived */
872+
try_count=0;
873+
while (!fileExists(ready_path))
874+
{
875+
sleep(1);
876+
if (interrupted)
877+
elog(ERROR,
878+
"interrupted during waiting for WAL archiving");
879+
try_count++;
880+
if (try_count>TIMEOUT_ARCHIVE)
881+
elog(ERROR,
882+
"switched WAL could not be archived in %d seconds",
883+
TIMEOUT_ARCHIVE);
884+
}
885+
}
886+
845887
/*
846888
* Notify end of backup to PostgreSQL server.
847889
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp