aboutsummaryrefslogtreecommitdiff
path: root/src/backend/replication/basebackup.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/replication/basebackup.c')
-rw-r--r--src/backend/replication/basebackup.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index 144b17c66b6..7929f855f6d 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -308,6 +308,15 @@ sendDir(char *path, int basepathlen, bool sizeonly)
strlen(PG_TEMP_FILE_PREFIX)) == 0)
continue;
+ /*
+ * Check if the postmaster has signaled us to exit, and abort
+ * with an 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)
+ ereport(ERROR,
+ (errmsg("shutdown requested, aborting active base backup")));
+
snprintf(pathbuf, MAXPGPATH, "%s/%s", path, de->d_name);
/* Skip postmaster.pid in the data directory */
@@ -462,7 +471,10 @@ sendFile(char *filename, int basepathlen, struct stat * statbuf)
while ((cnt = fread(buf, 1, Min(sizeof(buf), statbuf->st_size - len), fp)) > 0)
{
/* Send the chunk as a CopyData message */
- pq_putmessage('d', buf, cnt);
+ if (pq_putmessage('d', buf, cnt))
+ ereport(ERROR,
+ (errmsg("base backup could not send data, aborting backup")));
+
len += cnt;
if (len >= statbuf->st_size)