PgQue creates three database roles at install time:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/NikolayS/PgQue/llms.txt
Use this file to discover all available pages before exploring further.
pgque_reader, pgque_writer, and pgque_admin. The producer/consumer split mirrors upstream PgQ’s design — reader and writer are siblings, not parent/child — so a producer-only role cannot accidentally ack another consumer’s batch.
The three roles
| Role | Purpose | Key grants |
|---|---|---|
pgque_reader | Consumers, dashboards, metrics | receive, ack, nack, subscribe, unsubscribe, get_queue_info, get_consumer_info, dlq_inspect, select on all tables |
pgque_writer | Producers | send, send_batch, insert_event, dlq_replay, dlq_replay_all |
pgque_admin | Operators, migrations | Member of both pgque_reader and pgque_writer, plus create_queue, drop_queue, set_queue_config, start, stop, ticker, maint, status |
pgque_writer does not inherit pgque_reader. An app that both produces and consumes must be granted both roles explicitly.
DDL-class operations (create_queue, drop_queue, start, stop, maint, maint_retry_events, ticker, force_next_tick, set_queue_config) are not granted to either pgque_reader or pgque_writer — they require pgque_admin.
pgque.uninstall() is revoked from pgque_admin and PUBLIC; only the schema/install owner (typically a superuser) can run it.
Typical grant patterns
Roles are global, not per-queue
What this means in practice:pgque_readergetsselecton all tables in thepgqueschema — it can read events from any queuepgque_writercan produce to any queue- Batch IDs are bearer tokens — a caller that learns a valid
batch_idcanackit, regardless of which consumer opened it
Recommended isolation patterns
If you need mutually untrusted tenants sharing one database:- Separate databases per tenant — connect each tenant’s application to its own database. Cleanest isolation.
- Wrapper functions — wrap the PgQue API in app-owned stored functions that check tenant ownership before delegating to
pgque.*. Grant only the wrapper functions to tenant roles. - Separate schemas per tenant — run separate PgQue installs in separate schemas per tenant (not yet officially supported — check the roadmap).
