model-writtenrun 6152 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Michael Powers reported that logical-replication triggers executed pg_notify() without waking listeners, leaving notifications queued until a normal backend issued a notification #1; Sergei Kornilov traced this to missing ProcessCompletedNotifies() calls in logical workers #2.
- Marc Dean suggested calling notification processing near the end of apply_handle_commit() #4, and Sergei submitted a two-line worker-specific fix that passed check-world #5; Michael confirmed that it resolved his reproduction #7.
- Andres Freund proposed moving signaling into transaction commit so procedure-internal commits would also notify other sessions #6; Tom Lane warned against recursion and premature delivery to the originating client #8, and Andres clarified that signaling and frontend delivery should be separated while also flagging missing queue cleanup in background workers #9 #11.
- The issue remained unresolved for years: Robert Welin reported failure even with the initial patch #12, Marc described periodic inserts as a workaround #13, Daniel Danzberger reproduced the bug on PostgreSQL 12 #16, and Sergey Fedchenko reported success testing an adaptation of the initial patch on PostgreSQL 14 beta #17.
- Arthur Zakirov revived the work with a broader implementation that moved SignalBackends() into AtCommit_Notify(), using intervening changes that had removed the dependency on its return value #18.
- Tom found that Arthur's patch still allowed the notification queue to grow indefinitely when background workers sent notifications without normal listeners, and requested commit-time queue-tail advancement plus ordering comments and documentation changes #20; Arthur incorporated those changes in his revision #21.
- Tom rejected backpatching before PostgreSQL 13 because intervening async.c changes made it too risky, and proposed retaining ProcessCompletedNotifies() as a no-op in stable branches to preserve extension compatibility #22.
- Tom then revised Arthur's patch to route self-notifications through the existing ProcessNotifyInterrupt() path, eliminating duplicate queue reads and transactions, removing ProcessCompletedNotifies(), and avoiding an extra frontend flush #23.
- The revised notification patch #23 landed unchanged as 2e4eae87d0, with joint credit to Arthur Zakirov and Tom Lane and backpatches limited to PostgreSQL 13 and later; Tom announced the push in #24.
- Tom also identified that LISTEN in background workers could prevent notification-queue cleanup because those workers never consumed messages #23, then submitted a separate MyBackendType-based prohibition #24.
- At the thread's last message, Arthur endorsed the LISTEN restriction #25; it subsequently landed unchanged from #24 as 1316be2866, completing both fixes while leaving useful background-worker listening infrastructure for future work.