pg_topics
pg_topics · PostgreSQL tables as JSON topics with a Kafka-protocol listener
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 102467 | pg_topics | pg_topics | 0.1.0 | FEAT | PostgreSQL | Rust |
PostgreSQL · 17
| Relationships | |
|---|---|
| Requires | plpgsql |
Usage
Sources:
- README.md
- extension/pg_topics.control
- extension/Cargo.toml
- extension/src/lib.rs
- docs/configuration.md
- docs/sql.md
- docs/operations.md
- pg_topics.sql
pg_topics 0.1.0 exposes PostgreSQL tables as JSON event topics through SQL functions and a Kafka-protocol listener. The reviewed Supatype distribution documents PostgreSQL 17. It requires shared preloading, server-side TLS configuration and an externally enforced failover-fencing policy. It is not a complete Kafka implementation.
Enable a Database
Install matching PostgreSQL 17 libraries, append pg_topics to shared_preload_libraries, and configure pg_topics.databases, TLS certificate/key and pg_topics.advertised_host. Set pg_topics.failover_is_fenced only after ensuring an old primary cannot continue serving after promotion. Restart PostgreSQL, then create the nonrelocatable extension as a superuser in each allowed database; its schema is topic.
Publishing through SQL participates in the caller’s transaction. A band corresponds to a Kafka partition. Kafka clients use the full schema.table_q name, SASL_SSL, PLAIN authentication, and a PostgreSQL role/password. Grant topic access deliberately; Kafka does not introduce a separate authorization database.
Capacity and Delivery
The source registers five background workers per configured database: stamper, replicated stamper, partition, sync and listener. Reserve max_worker_processes accordingly. Each authenticated Kafka connection also holds a PostgreSQL connection, so size max_connections and pg_topics.max_clients together. An optional sync worker maintains a current-state table; ordinary SQL can read topic history.
Review topic durability and replication settings before changing acknowledgement behavior. A lost response may require a retry; idempotent and non-idempotent producers have different duplicate handling. PostgreSQL backup/recovery and the external fencing guarantee are part of the message-delivery design.
Compatibility Limits
Values must parse as JSON; keys are UTF-8 text of at most 40 characters, and table names must end in _q. Kafka transactions are unsupported. Use the upstream compatibility table when choosing client/admin APIs. Bound SQL fetch sizes, retention, connection counts and the number of databases; throughput examples from the project are measurements, not sizing guarantees.