On Sat, Sep 16, 2017 at 9:52 PM, Peter Eisentraut
<peter.eisentr...@2ndquadrant.com> wrote:
> On 9/15/17 13:35, Arseny Sher wrote:
>> Peter Eisentraut <peter.eisentr...@2ndquadrant.com> writes:
>>
>>> Here is a simple patch that fixes this, based on my original proposal
>>> point #4.
>>
>> I checked, it passes the tests and solves the problem. However, isn't
>> this
>>
>> +             if (slotname || !subenabled)
>>
>> is a truism? Is it possible that subscription has no slot but still
>> enabled?
>
> Yeah, we could just remove the _at_commit() branch entirely.  That would
> effectively undo the change in 7e174fa793a2df89fe03d002a5087ef67abcdde8,
> but I don't see any other choice for now.  And the practical impact
> would be quite limited.
>

Yeah, we can remove only _at_commit() branch, but other part of the
commit is still valid for ALTER SUBSCRIPTION DISABLE.

>> Besides, we can avoid stopping the workers if subscription has no
>> associated replication origin, though this probably means that
>> subscription was broken by user and is not worth it.
>
> Right, it seems not worth addressing this case separately.
>

Once we got this patch, DROP SUBSCRIPTION is not transactional either
if dropping a replication slot or if the subscription got disabled in
a transaction block. But we disallow to do DROP SUBSCRIPTION in a
transaction block only in the former case. In the latter case, we
adopted such non-transactional behaviour. Since these behaviours would
be complex for users I attached the documentation patch explaining it.

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center
diff --git a/doc/src/sgml/ref/drop_subscription.sgml b/doc/src/sgml/ref/drop_subscription.sgml
index f535c00..a7a786e 100644
--- a/doc/src/sgml/ref/drop_subscription.sgml
+++ b/doc/src/sgml/ref/drop_subscription.sgml
@@ -93,6 +93,14 @@ DROP SUBSCRIPTION [ IF EXISTS ] <replaceable class="parameter">name</replaceable
    reserve WAL and might eventually cause the disk to fill up.  See
    also <xref linkend="logical-replication-subscription-slot">.
   </para>
+
+  <para>
+   Since dropping a replication slot is not transactional, we cannot run
+   <command>DROP SUBSCRIPTION</command> inside a transaction block if dropping
+   the replication slot. Also, <command>DROP SUBSCRIPTOIN</command> stops the
+   workers if the subscription got disabled in a transaction block even if
+   the transaction rolls back.
+  </para>
  </refsect1>
 
  <refsect1>
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to