pg_kafka_events
Publishes PostgreSQL logical-decoding change events to Apache Kafka through a background worker.
pg_kafka_events · Publishes PostgreSQL logical-decoding change events to Apache Kafka through a background worker.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100341 | pg_kafka_events | pg_kafka_events | 1.0 | ETL | Apache-2.0 | C |
Usage
Sources:
- pg_kafka_events README at the reviewed commit
- pg_kafka_events.control at the reviewed commit
- Background-worker implementation
- Build dependencies
- Version 1.0 install SQL
pg_kafka_events is a preloaded background worker that forks pg_recvlogical, reads newline-delimited logical-decoding output, and publishes each change through librdkafka. The default decoder is decoding_json; one configured database is streamed to one Kafka topic.
Server Configuration
Install librdkafka, the chosen logical-decoding plugin, and the configured pg_recvlogical binary before restarting PostgreSQL. After restart, register the extension as a superuser:
The install SQL is empty; preloading starts the worker, while CREATE EXTENSION only records version 1.0 in that database.
Caveats
- The worker always uses the replication slot name
kafka_events. A stopped or failing consumer can retain WAL indefinitely; monitor slot lag and define an operator recovery procedure. - This 2017 implementation does not provide transactional grouping, acknowledgements exposed to PostgreSQL, retries coordinated with the replication position, or an exactly-once guarantee. Validate duplicates and loss behavior under Kafka and process failures.
- Decoder lines are accumulated in a fixed 64 KiB static buffer without a length guard. Large row-change messages can overrun it; do not deploy the reviewed code without remediation.
- Published payloads are also emitted as PostgreSQL notices, potentially copying row data into server logs. The only upstream tag is
0.1even though control and catalog use1.0.