On Thu, 3 Dec 2026 at 08:46, Nisha Moond <[email protected]> wrote: > > On Thu, Dec 3, 2026 at 2:39 AM Kirill Reshke <[email protected]> wrote: > > > > Hi! > > After the CLT feature committed [0] server nowl can deadlock if the > > subscription has a conflict-log table and DROP SUBSCRIPTION races with > > ALTER SUBSCRIPTION OWNER TO. > > > > Thanks for the report. I was able to reproduce the issue with concurrent > ALTER OWNER and DROP commands. Instead of the expected "tuple concurrently > deleted" error, the DROP fails with a deadlock: > Thanks for taking look.
On Thu, 3 Dec 2026 at 17:00, Shlok Kyal <[email protected]> wrote: > > > The deadlock error was like: > postgres=# DROP SUBSCRIPTION sub1; > ERROR: deadlock detected > DETAIL: Process 1197528 waits for AccessExclusiveLock on relation 16401 of > database 5; blocked by process 1197547. > Process 1197547 waits for ShareLock on transaction 689; blocked by process > 1197528. > > It happens because: > 1. DROP SUBSCRIPTION holds ExclusiveLock on its own XID (689). > CatalogTupleDelete() marks the subscription row deleted by that XID. > 2. ALTER SUBSCRIPTION ... OWNER TO acquires AccessExclusiveLock on the > conflict log table (16401). When it tries to update the same subscription > row, it sees the uncommitted deletion and requests ShareLock on XID 689 to > wait for the outcome. > AlterSubscriptionOwner_internal() > -> CatalogTupleUpdate() > -> simple_heap_update() > -> heap_update(wait = true) > -> XactLockTableWait(xwait = 689) > -> LockAcquire(&tag, ShareLock, false, false) > 3. DROP then requests AccessExclusiveLock on the conflict log table. ALTER > OWNER still holds that lock while waiting for DROP. > Hence a deadlock is reported. Yes, I described this in my report too in less detail. The deadlock is reachable with sequence . > To fix the deadlock can we move the 'CatalogTupleDelete(rel, &tup->t_self);' > after 'drop_sub_conflict_log_table'? > That would make DROP SUBSCRIPTION and ALTER SUBSCRIPTION ... OWNER TO acquire > the conflict log table lock before modifying the pg_subscription row. If > ALTER OWNER acquires the table lock first, DROP waits without marking the row > deleted, so ALTER OWNER can update the row and commit. If DROP acquires the > lock first, ALTER OWNER waits for the table lock before attempting to update > the row. > > Does it make sense or am I missing something? Is this fix the same as mine in the first message on the thread? I wrote > . I didn't find any core call sites who expect that tuple deletion should go > first, so done this way. So I think fixing this way is OK -- Best regards, Kirill Reshke
