pgq_coop
pgq-coop · Cooperative PgQ consumption across multiple connections
Overview
PostgreSQL · 14, 15, 16, 17, 18
| Relationships | |
|---|---|
| Requires | pgq |
Usage
Sources:
- README.rst
- pgq_coop.control
- Makefile
- mk/common-pgxs.mk
- sql/pgq_coop_test.sql
- functions/pgq_coop.next_batch.sql
- functions/pgq_coop.finish_batch.sql
- .github/workflows/ci.yml
pgq_coop 3.4 lets multiple connections consume one PgQ consumer cooperatively. The current upstream CI configuration covers PostgreSQL 14–18.
Core Workflow
Consumption and Maintenance
pgq_coop.next_batch returns a batch ID or NULL when no work is ready. Read its events using the normal PgQ batch API, complete application processing, then call pgq_coop.finish_batch(batch_id) with that returned ID. pgq_coop.next_batch_custom controls batch thresholds; the four-argument next-batch form accepts an inactivity interval for takeover. pgq_coop.unregister_subconsumer removes a worker registration.
Install as a superuser with the pgq dependency already available. The non-relocatable SQL extension creates the pgq_coop schema; its control selects pg_catalog as the installation schema. No new shared library or preload is required. PgQ still needs its normal ticker and maintenance. Worker failure and takeover can require reprocessing, so make handlers retry-safe; this extension does not replace a worker process.