What causes PostgreSQL to report:
ERROR: too many notifications in the NOTIFY queue
I reproduced it with PostgreSQL 17, Docker, and two psql sessions.
Instead of trying to fill PostgreSQL's default multi-gigabyte queue, I started the server with:
max_notify_queue_pages=64
With 8 KiB pages, that gave the experiment a queue capacity of only 512 KiB.
The listener did this:
LISTEN demo;
BEGIN;
and remained idle in transaction.
From another connection, I generated 100 large pg_notify() calls.
The result was easy to observe:
Successful sends: 64
Failed sends: 36
Queue usage: 100%
PostgreSQL reported:
ERROR: too many notifications in the NOTIFY queue
Then I returned to the listener and executed:
COMMIT;
Pending notifications were delivered and:
SELECT pg_notification_queue_usage();
returned to 0.
The useful takeaway is that increasing max_notify_queue_pages only gives the system more space. It does not remove a transaction that is preventing notification cleanup.
The full experiment includes the Docker Compose setup, SQL commands, queue measurements, inspection of pg_notify/, and recovery verification:
https://bodanthebackend.com/articles/en/postgresql-listen-notify-queue-full/
Top comments (0)