• Peter Eisentraut's avatar
    Fix DROP SUBSCRIPTION hang · 8edacab2
    Peter Eisentraut authored
    When ALTER SUBSCRIPTION DISABLE is run in the same transaction before
    DROP SUBSCRIPTION, the latter will hang because workers will still be
    running, not having seen the DISABLE committed, and DROP SUBSCRIPTION
    will wait until the workers have vacated the replication origin slots.
    
    Previously, DROP SUBSCRIPTION killed the logical replication workers
    immediately only if it was going to drop the replication slot, otherwise
    it scheduled the worker killing for the end of the transaction, as a
    result of 7e174fa7.  This, however,
    causes the present problem.  To fix, kill the workers immediately in all
    cases.  This covers all cases: A subscription that doesn't have a
    replication slot must be disabled.  It was either disabled in the same
    transaction, or it was already disabled before the current transaction,
    but then there shouldn't be any workers left and this won't make a
    difference.
    Reported-by: default avatarArseny Sher <a.sher@postgrespro.ru>
    Discussion: https://www.postgresql.org/message-id/flat/87mv6av84w.fsf%40ars-thinkpad
    8edacab2
007_ddl.pl 1.45 KB