October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

How to Reproduce a PostgreSQL LISTEN/NOTIFY Queue-Full Error

A safe, controlled recipe for reproducing a PostgreSQL LISTEN/NOTIFY queue-full failure with a 64-page queue and a stalled listener transaction.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

On a disposable PostgreSQL instance, set max_notify_queue_pages to 64, restart the server, and hold a transaction open in a session that has issued LISTEN. Then commit distinct NOTIFY payloads from another session until a producer transaction fails at commit. With 8 KB database pages, 64 pages configure a 512 KiB queue; that is capacity, not a guaranteed event count.

What the reproduction demonstrates

PostgreSQL retains notification events until listening sessions have processed them. If the notification queue fills, transactions that call NOTIFY fail when they try to commit—not necessarily when the NOTIFY statement is issued. A listener left in a long-running transaction can prevent queue cleanup. PostgreSQL documents that at half-full, log warnings point to the session preventing cleanup. See the PostgreSQL 18 NOTIFY documentation.

As an Amazon Associate I earn from qualifying purchases.

This is a controlled failure demonstration, not a production tuning recommendation. Use an isolated local instance: deliberately limiting the queue can cause notification-producing transactions to fail.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configure a small queue

  1. In the disposable server’s startup configuration, add max_notify_queue_pages = 64.

  2. Restart PostgreSQL; this parameter can only be set at server start.

  3. Connect to the test database and verify the active value with SHOW max_notify_queue_pages;.

The PostgreSQL 18 resource-consumption configuration documentation gives a default of 1,048,576 pages and describes that as 8 GB when pages are 8 KB. Under the same 8 KB page-size assumption, 64 pages equal 512 KiB (64 × 8 KiB). Recalculate if the installation uses a different database block size.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Hold cleanup back with a listener transaction

Open two sessions to the same database. In session A, register the listener and leave its transaction open:

LISTEN queue_repro;
BEGIN;
-- Leave this transaction open while the producer runs.

For this reproduction, run LISTEN before opening the long transaction. Keep session A connected and do not commit or roll it back while producing events; the open transaction is what prevents cleanup from advancing.

Produce distinct notifications and catch the commit error

In session B, send notifications on the subscribed channel in separate committed transactions, incrementing the payload each time. For example:

SELECT pg_notify('queue_repro', 'event-000001');

Repeat with payloads such as event-000002, event-000003, and so on. Ensure the client commits each statement as its own transaction and captures errors reported at commit. A client-side loop or script is useful, but the loop should stop and record the first failed transaction rather than treating the pg_notify call alone as proof of success.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a distinct payload for every transaction. PostgreSQL folds repeated notifications with the same channel and identical payload within a single transaction into one event. Distinct events committed separately make the queue pressure easier to observe and preserve transaction commit ordering.

Monitor queue usage and identify the blocker

From a third session, sample queue occupancy while the producer runs:

SELECT pg_notification_queue_usage();

The function reports the fraction of the queue occupied by pending notifications. Record the sampling time if comparing readings. PostgreSQL documents warnings in the server log at half-full, including the session that prevents cleanup; log access and formatting depend on the server’s logging setup.

The queue’s configured 512 KiB capacity does not imply a fixed number of notifications. Entry sizes and queue bookkeeping affect how many events fit, so the failure point is not a dependable event-count benchmark.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

End the blocking transaction and recover

After capturing the failure, or once you have finished the demonstration, release session A’s open transaction:

ROLLBACK;

Ending the long-running listener transaction allows cleanup to proceed. Confirm that queue usage can fall, then restore the instance’s normal configuration if you intend to keep using it.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep payload size separate from queue capacity

The notification payload has its own limit: in the default configuration it must be shorter than 8,000 bytes. That byte limit is distinct from the total queue capacity. For large or binary data, PostgreSQL recommends storing the content in a table and sending a key or identifier in the notification instead. See the NOTIFY command reference.

What LISTEN/NOTIFY is—and is not—suited to

LISTEN/NOTIFY is useful for signaling that database state changed. It should not be treated as a durable general-purpose message broker when consumers may stay stalled long enough to block cleanup. Before relying on it, consider whether every event must be retained, how long listeners may hold transactions open, expected payload size, how consumers recover after being offline, and whether they can reread authoritative state from a table.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For client applications using libpq, notifications are retrieved through the connection’s asynchronous notification handling; see PostgreSQL’s libpq asynchronous notification documentation. Implementation details such as the central queue and listener positions are described in PostgreSQL’s async.c source reference; development-source details can change over time.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.