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
</listitem>
<listitem>
- <para><literal>DROP_REPLICATION_SLOT <replaceable>slot_name</replaceable></literal></para>
+ <para><literal>DROP_REPLICATION_SLOT <replaceable>slot_name</replaceable></literal> <optional> <literal>WAIT</> </></para>
</listitem>
<listitem>
</varlistentry>
<varlistentry>
- <term><literal>DROP_REPLICATION_SLOT</literal> <replaceable class="parameter">slot_name</>
+ <term>
+ <literal>DROP_REPLICATION_SLOT</literal> <replaceable class="parameter">slot_name</> <optional> <literal>WAIT</> </optional>
<indexterm><primary>DROP_REPLICATION_SLOT</primary></indexterm>
</term>
<listitem>
<para>
- Drops a replication slot, freeing any reserved server-side resources. If
- the slot is currently in use by an active connection, this command fails.
+ Drops a replication slot, freeing any reserved server-side resources.
If the slot is a logical slot that was created in a database other than
the database the walsender is connected to, this command fails.
</para>
</para>
</listitem>
</varlistentry>
+
+ <varlistentry>
+ <term><literal>WAIT</literal></term>
+ <listitem>
+ <para>
+ This option causes the command to wait if the slot is active until
+ it becomes inactive, instead of the default behavior of raising an
+ error.
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</listitem>
</varlistentry>
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)
%token K_LABEL
%token K_PROGRESS
%token K_FAST
+%token K_WAIT
%token K_NOWAIT
%token K_MAX_RATE
%token K_WAL
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;
}
;
EXPORT_SNAPSHOT { return K_EXPORT_SNAPSHOT; }
NOEXPORT_SNAPSHOT { return K_NOEXPORT_SNAPSHOT; }
USE_SNAPSHOT { return K_USE_SNAPSHOT; }
+WAIT { return K_WAIT; }
"," { return ','; }
";" { return ';'; }
CheckSlotRequirements();
- ReplicationSlotDrop(NameStr(*name), false);
+ ReplicationSlotDrop(NameStr(*name), true);
PG_RETURN_VOID();
}
static void
DropReplicationSlot(DropReplicationSlotCmd *cmd)
{
- ReplicationSlotDrop(cmd->slotname, false);
+ ReplicationSlotDrop(cmd->slotname, !cmd->wait);
EndCommand("DROP_REPLICATION_SLOT", DestRemote);
}
{
NodeTag type;
char *slotname;
+ bool wait;
} DropReplicationSlotCmd;