diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2012-10-05 17:13:07 +0300 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2012-10-05 17:21:12 +0300 |
commit | fd5942c18f977a36fec66a8d1281092805f2a55e (patch) | |
tree | 722501422b9f52f412729096be8f49688212474c /src/backend/replication/basebackup.c | |
parent | 1997f34db4687e671690ed054c8f30bb501b1168 (diff) |
Use the regular main processing loop also in walsenders.
The regular backend's main loop handles signal handling and error recovery
better than the current WAL sender command loop does. For example, if the
client hangs and a SIGTERM is received before starting streaming, the
walsender will now terminate immediately, rather than hang until the
connection times out.
Diffstat (limited to 'src/backend/replication/basebackup.c')
-rw-r--r-- | src/backend/replication/basebackup.c | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c index 4636e8d1c6f..04681f41962 100644 --- a/src/backend/replication/basebackup.c +++ b/src/backend/replication/basebackup.c @@ -22,6 +22,7 @@ #include "lib/stringinfo.h" #include "libpq/libpq.h" #include "libpq/pqformat.h" +#include "miscadmin.h" #include "nodes/pg_list.h" #include "replication/basebackup.h" #include "replication/walsender.h" @@ -30,7 +31,6 @@ #include "storage/ipc.h" #include "utils/builtins.h" #include "utils/elog.h" -#include "utils/memutils.h" #include "utils/ps_status.h" typedef struct @@ -370,19 +370,10 @@ void SendBaseBackup(BaseBackupCmd *cmd) { DIR *dir; - MemoryContext backup_context; - MemoryContext old_context; basebackup_options opt; parse_basebackup_options(cmd->options, &opt); - backup_context = AllocSetContextCreate(CurrentMemoryContext, - "Streaming base backup context", - ALLOCSET_DEFAULT_MINSIZE, - ALLOCSET_DEFAULT_INITSIZE, - ALLOCSET_DEFAULT_MAXSIZE); - old_context = MemoryContextSwitchTo(backup_context); - WalSndSetState(WALSNDSTATE_BACKUP); if (update_process_title) @@ -403,9 +394,6 @@ SendBaseBackup(BaseBackupCmd *cmd) perform_base_backup(&opt, dir); FreeDir(dir); - - MemoryContextSwitchTo(old_context); - MemoryContextDelete(backup_context); } static void @@ -606,7 +594,7 @@ sendDir(char *path, int basepathlen, bool sizeonly) * error in that case. The error handler further up will call * do_pg_abort_backup() for us. */ - if (walsender_shutdown_requested || walsender_ready_to_stop) + if (ProcDiePending || walsender_ready_to_stop) ereport(ERROR, (errmsg("shutdown requested, aborting active base backup"))); |