Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8ba6d50

Browse files
committed
Add a WAIT option to DROP_REPLICATION_SLOT
Commit9915de6 changed the default behavior ofDROP_REPLICATION_SLOT so that it would wait until any session holdingthe slot active would release it, instead of raising an error. Butusers are already depending on the original behavior, so revert to it bydefault and add a WAIT option to invoke the new behavior.Per complaint from Simone Gotti, inDiscussion:https://postgr.es/m/CAEvsy6Wgdf90O6pUvg2wSVXL2omH5OPC-38OD4Zzgk-FXavj3Q@mail.gmail.com
1 parent28915c7 commit8ba6d50

File tree

8 files changed

+30
-7
lines changed

8 files changed

+30
-7
lines changed

‎doc/src/sgml/logicaldecoding.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ $ pg_recvlogical -d postgres --slot test --drop-slot
303303
</listitem>
304304

305305
<listitem>
306-
<para><literal>DROP_REPLICATION_SLOT <replaceable>slot_name</replaceable></literal></para>
306+
<para><literal>DROP_REPLICATION_SLOT <replaceable>slot_name</replaceable></literal> <optional> <literal>WAIT</> </></para>
307307
</listitem>
308308

309309
<listitem>

‎doc/src/sgml/protocol.sgml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,13 +2173,13 @@ The commands accepted in walsender mode are:
21732173
</varlistentry>
21742174

21752175
<varlistentry>
2176-
<term><literal>DROP_REPLICATION_SLOT</literal> <replaceable class="parameter">slot_name</>
2176+
<term>
2177+
<literal>DROP_REPLICATION_SLOT</literal> <replaceable class="parameter">slot_name</> <optional> <literal>WAIT</> </optional>
21772178
<indexterm><primary>DROP_REPLICATION_SLOT</primary></indexterm>
21782179
</term>
21792180
<listitem>
21802181
<para>
2181-
Drops a replication slot, freeing any reserved server-side resources. If
2182-
the slot is currently in use by an active connection, this command fails.
2182+
Drops a replication slot, freeing any reserved server-side resources.
21832183
If the slot is a logical slot that was created in a database other than
21842184
the database the walsender is connected to, this command fails.
21852185
</para>
@@ -2192,6 +2192,17 @@ The commands accepted in walsender mode are:
21922192
</para>
21932193
</listitem>
21942194
</varlistentry>
2195+
2196+
<varlistentry>
2197+
<term><literal>WAIT</literal></term>
2198+
<listitem>
2199+
<para>
2200+
This option causes the command to wait if the slot is active until
2201+
it becomes inactive, instead of the default behavior of raising an
2202+
error.
2203+
</para>
2204+
</listitem>
2205+
</varlistentry>
21952206
</variablelist>
21962207
</listitem>
21972208
</varlistentry>

‎src/backend/commands/subscriptioncmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
959959
load_file("libpqwalreceiver", false);
960960

961961
initStringInfo(&cmd);
962-
appendStringInfo(&cmd,"DROP_REPLICATION_SLOT %s",quote_identifier(slotname));
962+
appendStringInfo(&cmd,"DROP_REPLICATION_SLOT %s WAIT",quote_identifier(slotname));
963963

964964
wrconn=walrcv_connect(conninfo, true,subname,&err);
965965
if (wrconn==NULL)

‎src/backend/replication/repl_gram.y

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ static SQLCmd *make_sqlcmd(void);
7272
%tokenK_LABEL
7373
%tokenK_PROGRESS
7474
%tokenK_FAST
75+
%tokenK_WAIT
7576
%tokenK_NOWAIT
7677
%tokenK_MAX_RATE
7778
%tokenK_WAL
@@ -272,6 +273,15 @@ drop_replication_slot:
272273
DropReplicationSlotCmd *cmd;
273274
cmd = makeNode(DropReplicationSlotCmd);
274275
cmd->slotname =$2;
276+
cmd->wait =false;
277+
$$ = (Node *) cmd;
278+
}
279+
|K_DROP_REPLICATION_SLOTIDENTK_WAIT
280+
{
281+
DropReplicationSlotCmd *cmd;
282+
cmd = makeNode(DropReplicationSlotCmd);
283+
cmd->slotname =$2;
284+
cmd->wait =true;
275285
$$ = (Node *) cmd;
276286
}
277287
;

‎src/backend/replication/repl_scanner.l

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ TEMPORARY{ return K_TEMPORARY; }
103103
EXPORT_SNAPSHOT{return K_EXPORT_SNAPSHOT; }
104104
NOEXPORT_SNAPSHOT{return K_NOEXPORT_SNAPSHOT; }
105105
USE_SNAPSHOT{return K_USE_SNAPSHOT; }
106+
WAIT{return K_WAIT; }
106107

107108
","{return','; }
108109
";"{return';'; }

‎src/backend/replication/slotfuncs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ pg_drop_replication_slot(PG_FUNCTION_ARGS)
171171

172172
CheckSlotRequirements();
173173

174-
ReplicationSlotDrop(NameStr(*name),false);
174+
ReplicationSlotDrop(NameStr(*name),true);
175175

176176
PG_RETURN_VOID();
177177
}

‎src/backend/replication/walsender.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
10281028
staticvoid
10291029
DropReplicationSlot(DropReplicationSlotCmd*cmd)
10301030
{
1031-
ReplicationSlotDrop(cmd->slotname,false);
1031+
ReplicationSlotDrop(cmd->slotname,!cmd->wait);
10321032
EndCommand("DROP_REPLICATION_SLOT",DestRemote);
10331033
}
10341034

‎src/include/nodes/replnodes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ typedef struct DropReplicationSlotCmd
6868
{
6969
NodeTagtype;
7070
char*slotname;
71+
boolwait;
7172
}DropReplicationSlotCmd;
7273

7374

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp