mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Implement NOWAIT option for BASE_BACKUP command
Specifying this option makes the server not wait for the xlog to be archived, or emit a warning that it can't, instead leaving the responsibility with the client. This is useful when the log is being streamed using the streaming protocol in parallel with the backup, without having log archiving enabled.
This commit is contained in:
@@ -37,6 +37,7 @@ typedef struct
|
||||
const char *label;
|
||||
bool progress;
|
||||
bool fastcheckpoint;
|
||||
bool nowait;
|
||||
bool includewal;
|
||||
} basebackup_options;
|
||||
|
||||
@@ -173,7 +174,7 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
|
||||
}
|
||||
PG_END_ENSURE_ERROR_CLEANUP(base_backup_cleanup, (Datum) 0);
|
||||
|
||||
endptr = do_pg_stop_backup(labelfile);
|
||||
endptr = do_pg_stop_backup(labelfile, !opt->nowait);
|
||||
|
||||
if (opt->includewal)
|
||||
{
|
||||
@@ -260,6 +261,7 @@ parse_basebackup_options(List *options, basebackup_options *opt)
|
||||
bool o_label = false;
|
||||
bool o_progress = false;
|
||||
bool o_fast = false;
|
||||
bool o_nowait = false;
|
||||
bool o_wal = false;
|
||||
|
||||
MemSet(opt, 0, sizeof(*opt));
|
||||
@@ -294,6 +296,15 @@ parse_basebackup_options(List *options, basebackup_options *opt)
|
||||
opt->fastcheckpoint = true;
|
||||
o_fast = true;
|
||||
}
|
||||
else if (strcmp(defel->defname, "nowait") == 0)
|
||||
{
|
||||
if (o_nowait)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("duplicate option \"%s\"", defel->defname)));
|
||||
opt->nowait = true;
|
||||
o_nowait = true;
|
||||
}
|
||||
else if (strcmp(defel->defname, "wal") == 0)
|
||||
{
|
||||
if (o_wal)
|
||||
|
||||
@@ -71,6 +71,7 @@ Node *replication_parse_result;
|
||||
%token K_LABEL
|
||||
%token K_PROGRESS
|
||||
%token K_FAST
|
||||
%token K_NOWAIT
|
||||
%token K_WAL
|
||||
%token K_START_REPLICATION
|
||||
|
||||
@@ -107,7 +108,7 @@ identify_system:
|
||||
;
|
||||
|
||||
/*
|
||||
* BASE_BACKUP [LABEL '<label>'] [PROGRESS] [FAST] [WAL]
|
||||
* BASE_BACKUP [LABEL '<label>'] [PROGRESS] [FAST] [WAL] [NOWAIT]
|
||||
*/
|
||||
base_backup:
|
||||
K_BASE_BACKUP base_backup_opt_list
|
||||
@@ -142,6 +143,11 @@ base_backup_opt:
|
||||
$$ = makeDefElem("wal",
|
||||
(Node *)makeInteger(TRUE));
|
||||
}
|
||||
| K_NOWAIT
|
||||
{
|
||||
$$ = makeDefElem("nowait",
|
||||
(Node *)makeInteger(TRUE));
|
||||
}
|
||||
;
|
||||
|
||||
/*
|
||||
|
||||
@@ -60,6 +60,7 @@ BASE_BACKUP { return K_BASE_BACKUP; }
|
||||
FAST { return K_FAST; }
|
||||
IDENTIFY_SYSTEM { return K_IDENTIFY_SYSTEM; }
|
||||
LABEL { return K_LABEL; }
|
||||
NOWAIT { return K_NOWAIT; }
|
||||
PROGRESS { return K_PROGRESS; }
|
||||
WAL { return K_WAL; }
|
||||
START_REPLICATION { return K_START_REPLICATION; }
|
||||
|
||||
Reference in New Issue
Block a user