mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-02-03 14:01:57 +02:00
Add backup option --archive-timeout
This commit is contained in:
parent
3a7b6d5de4
commit
f3bdedcf4d
19
backup.c
19
backup.c
@ -27,12 +27,12 @@
|
||||
#include "streamutil.h"
|
||||
#include "receivelog.h"
|
||||
|
||||
/* wait 10 sec until WAL archive complete */
|
||||
#define TIMEOUT_ARCHIVE 10
|
||||
|
||||
/* Server version */
|
||||
static int server_version = 0;
|
||||
|
||||
/* Wait timeout for WAL segment archiving */
|
||||
uint32 archive_timeout = 0;
|
||||
|
||||
static bool in_backup = false; /* TODO: more robust logic */
|
||||
static int standby_message_timeout = 10 * 1000; /* 10 sec = default */
|
||||
static XLogRecPtr stop_backup_lsn = InvalidXLogRecPtr;
|
||||
@ -737,7 +737,7 @@ wait_archive_lsn(XLogRecPtr lsn, bool prev_segno)
|
||||
XLogSegNo targetSegNo;
|
||||
char wal_path[MAXPGPATH];
|
||||
char wal_file[MAXFNAMELEN];
|
||||
int try_count = 0;
|
||||
uint32 try_count = 0;
|
||||
|
||||
tli = get_current_timeline(false);
|
||||
|
||||
@ -748,7 +748,6 @@ wait_archive_lsn(XLogRecPtr lsn, bool prev_segno)
|
||||
XLogFileName(wal_file, tli, targetSegNo);
|
||||
|
||||
join_path_components(wal_path, arclog_path, wal_file);
|
||||
elog(LOG, "wait for lsn %li in archived WAL segment %s", lsn, wal_path);
|
||||
|
||||
/* Wait until switched WAL is archived */
|
||||
while (!fileExists(wal_path))
|
||||
@ -757,10 +756,16 @@ wait_archive_lsn(XLogRecPtr lsn, bool prev_segno)
|
||||
if (interrupted)
|
||||
elog(ERROR, "interrupted during waiting for WAL archiving");
|
||||
try_count++;
|
||||
if (try_count > TIMEOUT_ARCHIVE)
|
||||
|
||||
/* Inform user if WAL segment is absent in first attempt */
|
||||
if (try_count == 1)
|
||||
elog(INFO, "wait for lsn %X/%X in archived WAL segment %s",
|
||||
(uint32) (lsn >> 32), (uint32) lsn, wal_path);
|
||||
|
||||
if (archive_timeout > 0 && try_count > archive_timeout)
|
||||
elog(ERROR,
|
||||
"switched WAL could not be archived in %d seconds",
|
||||
TIMEOUT_ARCHIVE);
|
||||
archive_timeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,6 +410,10 @@ Backup mode. Supported modes are: FULL (full backup), PAGE (incremental backup,
|
||||
|
||||
Makes an autonomous backup that includes all necessary WAL files, by streaming them from database server via replication protocol.
|
||||
|
||||
--archive-timeout
|
||||
|
||||
Wait timeout for WAL segment archiving. `pg_probackup` waits after `pg_start_backup()` and `pg_stop_backup()` executing when WAL segments with necessary LSN will be archived. For backup from master WAL segment will be archived fast, because master instance switch WAL segment during backup. For backup from standby `pg_probackup` will wait a long time, because standby instance cannot switch WAL segment. By default timeout is infinite.
|
||||
|
||||
-S _slot\_name_
|
||||
--slot=_slot\_name_
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
const char *PROGRAM_VERSION = "1.1.1";
|
||||
const char *PROGRAM_VERSION = "1.1.2";
|
||||
const char *PROGRAM_URL = "https://github.com/postgrespro/pg_probackup";
|
||||
const char *PROGRAM_EMAIL = "https://github.com/postgrespro/pg_probackup/issues";
|
||||
|
||||
@ -69,6 +69,7 @@ static pgut_option options[] =
|
||||
{ 'f', 'b', "backup-mode", opt_backup_mode, SOURCE_CMDLINE },
|
||||
{ 'b', 'C', "smooth-checkpoint", &smooth_checkpoint, SOURCE_CMDLINE },
|
||||
{ 's', 'S', "slot", &replication_slot, SOURCE_CMDLINE },
|
||||
{ 'u', 2, "archive-timeout", &archive_timeout, SOURCE_CMDLINE },
|
||||
/* options with only long name (keep-xxx) */
|
||||
/* restore options */
|
||||
{ 's', 3, "time", &target_time, SOURCE_CMDLINE },
|
||||
@ -250,6 +251,7 @@ pgut_help(bool details)
|
||||
printf(_(" -b, --backup-mode=MODE backup mode (full, page, ptrack)\n"));
|
||||
printf(_(" -C, --smooth-checkpoint do smooth checkpoint before backup\n"));
|
||||
printf(_(" --stream stream the transaction log and include it in the backup\n"));
|
||||
printf(_(" --archive-timeout wait timeout for WAL segment archiving\n"));
|
||||
printf(_(" -S, --slot=SLOTNAME replication slot to use\n"));
|
||||
printf(_(" --backup-pg-log backup of pg_log directory\n"));
|
||||
printf(_(" -j, --threads=NUM number of parallel threads\n"));
|
||||
|
@ -225,6 +225,7 @@ extern bool stream_wal;
|
||||
extern bool from_replica;
|
||||
extern bool progress;
|
||||
extern bool delete_wal;
|
||||
extern uint32 archive_timeout;
|
||||
|
||||
extern uint64 system_identifier;
|
||||
|
||||
|
@ -18,6 +18,7 @@ Backup options:
|
||||
-b, --backup-mode=MODE backup mode (full, page, ptrack)
|
||||
-C, --smooth-checkpoint do smooth checkpoint before backup
|
||||
--stream stream the transaction log and include it in the backup
|
||||
--archive-timeout wait timeout for WAL segment archiving
|
||||
-S, --slot=SLOTNAME replication slot to use
|
||||
--backup-pg-log backup of pg_log directory
|
||||
-j, --threads=NUM number of parallel threads
|
||||
|
@ -1 +1 @@
|
||||
pg_probackup 1.1.1
|
||||
pg_probackup 1.1.2
|
||||
|
Loading…
x
Reference in New Issue
Block a user