Skip to main content

Availability and failover

PostgreMQ's stored state is PostgreSQL data. Its availability and durability therefore depend on the database deployment: primary availability, WAL durability, replication, and the mechanism used to promote or recover a server.

Applications also need a recovery policy for open claims and uncertain operations. A reachable replacement primary does not by itself prove that an interrupted publication failed or that an old consumer still owns its deliveries.

Choose durability deliberately​

Connect publishers and consumers to the writable primary. Queue operations require writes even when the application is receiving work. A read replica is not a consumer endpoint.

Choose PostgreSQL replication and commit settings according to acceptable data loss and latency. Asynchronous replication can leave recently committed work absent from a promoted replica. PostgreMQ does not add a replication quorum above PostgreSQL or preserve messages that the database recovery loses. See PostgreSQL's high availability guidance.

Prevent application traffic from continuing against an old writable primary after promotion. Database endpoint routing and fencing are deployment responsibilities. Queue ownership tokens do not solve split-brain between divergent databases.

What applications observe​

During an outageConsequence
Publish or transaction commit loses its responseThe operation may have committed; retry can duplicate publication.
Claim or settlement cannot completeDo not infer delivery state from a transport error alone.
Automatic extension cannot confirm ownershipThe SDK eventually signals the delivery to stop; old application work must respond.
Exclusive lifetime is not extendedThe queue can expire before connectivity returns.
LISTEN connection is interruptedNotifications during the interruption are not replayed as a message log; polling discovers stored work.

The SDKs manage their listener connection and polling, but application code must observe consumer termination and queue-loss signals. Recovering a transport connection is different from recreating an expired or replaced queue. A Durable queue retains its backlog in the recovered database; an expired Exclusive subscription must be replaced and can miss events.

Use application IDs and idempotent consumers to reconcile ambiguous publication and effects. Do not reconnect and automatically assume every failed operation is safe to repeat.

Rehearse failover​

Use an isolated deployment with the same topology, endpoint-routing mechanism, and replication policy intended for production. Record baseline queue counts and application event IDs. Run publications, ordinary consumers, a long-running delivery, and an Exclusive subscription while monitoring maintenance.

Trigger failover through the database platform's supported procedure. Observe endpoint switch time, operation errors, reconnection, notification restoration, redelivery, and Exclusive lifetime. Keep the application's deployment termination budget and query deadlines realistic.

After promotion, verify:

  1. All application and maintenance traffic reaches the intended writable primary.
  2. Schema discovery and CLI status match the expected release and clean state.
  3. New publication and acknowledgement succeed with runtime credentials.
  4. Durable backlogs resume and duplicate effects are handled correctly.
  5. Expired subscriptions are reported and recreated according to application policy.
  6. Maintenance and monitoring have resumed against the recovered database.

Compare acknowledged application results with recovered database state using the durability expectations selected earlier. A no-error smoke test does not establish that every pre-failover commit survived.

Recover beyond reconnecting​

If failover or restore loses acknowledged queue state, external systems may still contain effects from the old timeline. Conversely, restored queue state may contain messages already processed externally. Reconciliation belongs in the recovery plan.

Use Backup and recovery for restore-specific steps, Graceful shutdown for controlled application stops, and Repeated deliveries or lost leases when recovery produces unexpected overlap.