How PostgreSQL's NOTIFY Queue Fills Up and How to Clear It

A developer reproduced the PostgreSQL 'too many notifications in the NOTIFY queue' error using PostgreSQL 17, Docker, and a deliberately limited queue size of 512 KiB set via the max_notify_queue_pages parameter. With a listener session held idle inside an open transaction, 100 large pg_notify() calls were issued from a second connection, filling the queue entirely after 64 successful sends and causing 36 to fail. The key finding is that an open transaction on the listener side blocks notification cleanup, regardless of how large the queue is configured. Simply committing the idle transaction allowed all pending notifications to be delivered and the queue usage returned to zero. This demonstrates that raising max_notify_queue_pages only delays the problem — the real fix is ensuring listener transactions do not remain open unnecessarily.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.




Discussion (0)
Log in to join the discussion and vote.
Log in