pg_replayfeed
pg_replayfeed · WAL-native key-only change streams with logical replication slots
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 102062 | pg_replayfeed | pg_replayfeed | 2.0 | ETL | MIT | C |
PostgreSQL · 16, 17, 18
Usage
Sources:
- Official README.md
- Official pg_replayfeed.control
- Official pg_replayfeed–2.0.sql
- Official semantics.md
- Official security.md
- Official ci.yml
pg_replayfeed 2.0 exposes key-only change envelopes from logical decoding. A committed transaction produces a JSON envelope; consumers checkpoint its commit LSN and handle possible redelivery. The reviewed development revision has a PostgreSQL 16–18 CI matrix.
Register and Read a Feed
Set logical WAL and sufficient replication slots and senders; restart when changing these startup settings. The extension does not require shared preload.
Run this administrative example as a superuser. create_feed accepts an ordinary logged table and a NOT NULL key backed by a single-column unique index; it sets REPLICA IDENTITY FULL. Inspect replayfeed.feed and remove a registration with replayfeed.drop_feed. Dropping a feed does not delete replication slots.
Consumers, Privileges and Retention
pg_logical_slot_get_changes consumes and advances a slot; pg_logical_slot_peek_changes does not. Replication clients can instead stream with the PostgreSQL replication protocol. Acknowledge only after durable processing and deduplicate by commit position. Key changes, tenant moves and truncation require the consumer to follow the documented envelope semantics.
The fixed replayfeed schema contains privileged SECURITY DEFINER administration functions with PUBLIC execution revoked. Delegated administrators need explicit schema/function grants and the checked source-table privileges. A replication role also needs catalog visibility. Feed selection is a filter, not tenant authorization; downstream consumers must enforce isolation.
Monitor slot lag and WAL disk use. An inactive slot retains WAL until advanced or removed; remove the demonstration slot after use: