aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlogfuncs.c
diff options
context:
space:
mode:
authorStephen Frost <sfrost@snowman.net>2017-03-22 23:44:58 -0400
committerStephen Frost <sfrost@snowman.net>2017-03-22 23:44:58 -0400
commit017e4f2588a7fc6f2d1fbb6fff8afa1ff6e31f2b (patch)
tree6684c386c0d35fd059018e56a15b1ebfa3481879 /src/backend/access/transam/xlogfuncs.c
parentcbf7ed51b8c0c3e506b91765769f76d5c2e1e9ac (diff)
downloadpostgresql-017e4f2588a7fc6f2d1fbb6fff8afa1ff6e31f2b.tar.gz
postgresql-017e4f2588a7fc6f2d1fbb6fff8afa1ff6e31f2b.zip
Expose waitforarchive option through pg_stop_backup()
Internally, we have supported the option to either wait for all of the WAL associated with a backup to be archived, or to return immediately. This option is useful to users of pg_stop_backup() as well, when they are reading the stop backup record position and checking that the WAL they need has been archived independently. This patch adds an additional, optional, argument to pg_stop_backup() which allows the user to indicate if they wish to wait for the WAL to be archived or not. The default matches current behavior, which is to wait. Author: David Steele, with some minor changes, doc updates by me. Reviewed by: Takayuki Tsunakawa, Fujii Masao Discussion: https://postgr.es/m/758e3fd1-45b4-5e28-75cd-e9e7f93a4c02@pgmasters.net
Diffstat (limited to 'src/backend/access/transam/xlogfuncs.c')
-rw-r--r--src/backend/access/transam/xlogfuncs.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/backend/access/transam/xlogfuncs.c b/src/backend/access/transam/xlogfuncs.c
index 96aa15e9cc3..5073aaca84f 100644
--- a/src/backend/access/transam/xlogfuncs.c
+++ b/src/backend/access/transam/xlogfuncs.c
@@ -175,6 +175,13 @@ pg_stop_backup(PG_FUNCTION_ARGS)
* the backup label and tablespace map files as text fields in as part of the
* resultset.
*
+ * The first parameter (variable 'exclusive') allows the user to tell us if
+ * this is an exclusive or a non-exclusive backup.
+ *
+ * The second paramter (variable 'waitforarchive'), which is optional,
+ * allows the user to choose if they want to wait for the WAL to be archived
+ * or if we should just return as soon as the WAL record is written.
+ *
* Permission checking for this function is managed through the normal
* GRANT system.
*/
@@ -190,6 +197,7 @@ pg_stop_backup_v2(PG_FUNCTION_ARGS)
bool nulls[3];
bool exclusive = PG_GETARG_BOOL(0);
+ bool waitforarchive = PG_GETARG_BOOL(1);
XLogRecPtr stoppoint;
/* check to see if caller supports us returning a tuplestore */
@@ -232,7 +240,7 @@ pg_stop_backup_v2(PG_FUNCTION_ARGS)
* Stop the exclusive backup, and since we're in an exclusive backup
* return NULL for both backup_label and tablespace_map.
*/
- stoppoint = do_pg_stop_backup(NULL, true, NULL);
+ stoppoint = do_pg_stop_backup(NULL, waitforarchive, NULL);
exclusive_backup_running = false;
nulls[1] = true;
@@ -250,7 +258,7 @@ pg_stop_backup_v2(PG_FUNCTION_ARGS)
* Stop the non-exclusive backup. Return a copy of the backup label
* and tablespace map so they can be written to disk by the caller.
*/
- stoppoint = do_pg_stop_backup(label_file->data, true, NULL);
+ stoppoint = do_pg_stop_backup(label_file->data, waitforarchive, NULL);
nonexclusive_backup_running = false;
cancel_before_shmem_exit(nonexclusive_base_backup_cleanup, (Datum) 0);