mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +03:00
Exit from base backups when shutdown is requested
When the exit waits until the whole backup completes, it may take a very long time. In passing, add back an error check in the main loop so we detect clients that disconnect much earlier if the backup is large.
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user