aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2017-09-01 13:44:14 +0200
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2017-09-01 13:53:34 +0200
commit8ba6d50f923bfc1d7cc91f5ff11e199f18d7fd80 (patch)
treed1ca0551c8f12b09dc902deb2630b28214be4e4a /src
parent28915c7db4da4eaffb8eb0dc5c04c87dcf345eb6 (diff)
downloadpostgresql-8ba6d50f923bfc1d7cc91f5ff11e199f18d7fd80.tar.gz
postgresql-8ba6d50f923bfc1d7cc91f5ff11e199f18d7fd80.zip
Add a WAIT option to DROP_REPLICATION_SLOT
Commit 9915de6c1cb2 changed the default behavior of DROP_REPLICATION_SLOT so that it would wait until any session holding the slot active would release it, instead of raising an error. But users are already depending on the original behavior, so revert to it by default and add a WAIT option to invoke the new behavior. Per complaint from Simone Gotti, in Discussion: https://postgr.es/m/CAEvsy6Wgdf90O6pUvg2wSVXL2omH5OPC-38OD4Zzgk-FXavj3Q@mail.gmail.com
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/subscriptioncmds.c2
-rw-r--r--src/backend/replication/repl_gram.y10
-rw-r--r--src/backend/replication/repl_scanner.l1
-rw-r--r--src/backend/replication/slotfuncs.c2
-rw-r--r--src/backend/replication/walsender.c2
-rw-r--r--src/include/nodes/replnodes.h1
6 files changed, 15 insertions, 3 deletions
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index 005e74201d4..77620dfd429 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -959,7 +959,7 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
load_file("libpqwalreceiver", false);
initStringInfo(&cmd);
- appendStringInfo(&cmd, "DROP_REPLICATION_SLOT %s", quote_identifier(slotname));
+ appendStringInfo(&cmd, "DROP_REPLICATION_SLOT %s WAIT", quote_identifier(slotname));
wrconn = walrcv_connect(conninfo, true, subname, &err);
if (wrconn == NULL)
diff --git a/src/backend/replication/repl_gram.y b/src/backend/replication/repl_gram.y
index ec047c827cf..a012447fa2a 100644
--- a/src/backend/replication/repl_gram.y
+++ b/src/backend/replication/repl_gram.y
@@ -72,6 +72,7 @@ static SQLCmd *make_sqlcmd(void);
%token K_LABEL
%token K_PROGRESS
%token K_FAST
+%token K_WAIT
%token K_NOWAIT
%token K_MAX_RATE
%token K_WAL
@@ -272,6 +273,15 @@ drop_replication_slot:
DropReplicationSlotCmd *cmd;
cmd = makeNode(DropReplicationSlotCmd);
cmd->slotname = $2;
+ cmd->wait = false;
+ $$ = (Node *) cmd;
+ }
+ | K_DROP_REPLICATION_SLOT IDENT K_WAIT
+ {
+ DropReplicationSlotCmd *cmd;
+ cmd = makeNode(DropReplicationSlotCmd);
+ cmd->slotname = $2;
+ cmd->wait = true;
$$ = (Node *) cmd;
}
;
diff --git a/src/backend/replication/repl_scanner.l b/src/backend/replication/repl_scanner.l
index 52ae7b343fb..62bb5288c01 100644
--- a/src/backend/replication/repl_scanner.l
+++ b/src/backend/replication/repl_scanner.l
@@ -103,6 +103,7 @@ TEMPORARY { return K_TEMPORARY; }
EXPORT_SNAPSHOT { return K_EXPORT_SNAPSHOT; }
NOEXPORT_SNAPSHOT { return K_NOEXPORT_SNAPSHOT; }
USE_SNAPSHOT { return K_USE_SNAPSHOT; }
+WAIT { return K_WAIT; }
"," { return ','; }
";" { return ';'; }
diff --git a/src/backend/replication/slotfuncs.c b/src/backend/replication/slotfuncs.c
index d4cbd83bde1..ab776e85d2f 100644
--- a/src/backend/replication/slotfuncs.c
+++ b/src/backend/replication/slotfuncs.c
@@ -171,7 +171,7 @@ pg_drop_replication_slot(PG_FUNCTION_ARGS)
CheckSlotRequirements();
- ReplicationSlotDrop(NameStr(*name), false);
+ ReplicationSlotDrop(NameStr(*name), true);
PG_RETURN_VOID();
}
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 03e1cf44dee..db346e6edbd 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -1028,7 +1028,7 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
static void
DropReplicationSlot(DropReplicationSlotCmd *cmd)
{
- ReplicationSlotDrop(cmd->slotname, false);
+ ReplicationSlotDrop(cmd->slotname, !cmd->wait);
EndCommand("DROP_REPLICATION_SLOT", DestRemote);
}
diff --git a/src/include/nodes/replnodes.h b/src/include/nodes/replnodes.h
index dea61e90e96..2053ffabe09 100644
--- a/src/include/nodes/replnodes.h
+++ b/src/include/nodes/replnodes.h
@@ -68,6 +68,7 @@ typedef struct DropReplicationSlotCmd
{
NodeTag type;
char *slotname;
+ bool wait;
} DropReplicationSlotCmd;