model-writtenrun 3771 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Tomas Vondra reported a reproducible deadlock during concurrent publication changes and subscription refreshes: the apply worker held a subscription lock while waiting on a latch for tablesync workers blocked behind the refresh backend, making the cycle invisible to deadlock detection #1; he clarified that the conflicting lock was on the subscription object, not pg_subscription_rel #3.
- Amit Kapila proposed committing the apply worker's transaction before waiting #4, Tomas confirmed that the proposed approach prevented reproduction #5, and Amit requested statistics reporting after the commit #6.
- Shlok Kyal reproduced the problem across PostgreSQL 11 through the development version #8 and submitted a patch implementing the transaction boundary and statistics reporting, tested from PostgreSQL 12 through HEAD #9.
- Amit identified a stale comment and requested performance measurements #10; Shlok supplied subscription-test and table-synchronization timings #11 and clarified that they were medians of ten runs #17, while Tomas questioned whether the differences exceeded ordinary timing variation and emphasized fixing the indefinite wait #13.
- Amit proposed moving the commit inside the waiting function to avoid unnecessary transaction boundaries #12 #14; Shlok submitted both that experiment and the original approach with a corrected comment, reporting essentially equal performance and preferring the original implementation #18.
- Amit retained the original approach, reported comparable test timings in his environment, and posted a revision with improved comments and a rewritten commit message while crediting Shlok as author #19.
- Shlok verified that the revised patch resolved the deadlock and passed tests across PostgreSQL 12 through the development branch #20, and Amit independently confirmed the fix on older branches before announcing his intention to commit #21.
- Amit incorporated Peter Smith's offlist suggestion to simplify the conditional transaction handling and announced the push #22; the resulting master commit 8d7d2197f3 and PostgreSQL 12 backport e81e617f32 contain the same fix from #19 with only light readability edits.
- The fix was committed and backpatched through PostgreSQL 12, the experimental alternative was left out, and Tomas closed the thread by thanking the contributors with no further unresolved issue raised #22 #23.