mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Backend support for streaming base backups
Add BASE_BACKUP command to walsender, allowing it to stream a base backup to the client (in tar format). The syntax is still far from ideal, that will be fixed in the switch to use a proper grammar for walsender. No client included yet, will come as a separate commit. Magnus Hagander and Heikki Linnakangas
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
#include "libpq/pqformat.h"
|
||||
#include "libpq/pqsignal.h"
|
||||
#include "miscadmin.h"
|
||||
#include "replication/basebackup.h"
|
||||
#include "replication/walprotocol.h"
|
||||
#include "replication/walsender.h"
|
||||
#include "storage/fd.h"
|
||||
@@ -54,6 +55,7 @@
|
||||
#include "utils/guc.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/ps_status.h"
|
||||
#include "utils/resowner.h"
|
||||
|
||||
|
||||
/* Array of WalSnds in shared memory */
|
||||
@@ -136,6 +138,9 @@ WalSenderMain(void)
|
||||
ALLOCSET_DEFAULT_MAXSIZE);
|
||||
MemoryContextSwitchTo(walsnd_context);
|
||||
|
||||
/* Set up resource owner */
|
||||
CurrentResourceOwner = ResourceOwnerCreate(NULL, "walsender top-level resource owner");
|
||||
|
||||
/* Unblock signals (they were blocked when the postmaster forked us) */
|
||||
PG_SETMASK(&UnBlockSig);
|
||||
|
||||
@@ -305,6 +310,15 @@ WalSndHandshake(void)
|
||||
/* break out of the loop */
|
||||
replication_started = true;
|
||||
}
|
||||
else if (strncmp(query_string, "BASE_BACKUP ", 12) == 0)
|
||||
{
|
||||
/* Command is BASE_BACKUP <options>;<label> */
|
||||
SendBaseBackup(query_string + strlen("BASE_BACKUP "));
|
||||
/* Send CommandComplete and ReadyForQuery messages */
|
||||
EndCommand("SELECT", DestRemote);
|
||||
ReadyForQuery(DestRemote);
|
||||
/* ReadyForQuery did pq_flush for us */
|
||||
}
|
||||
else
|
||||
{
|
||||
ereport(FATAL,
|
||||
|
||||
Reference in New Issue
Block a user