Skip to content

kafgres

Kafka protocol broker embedded in PostgreSQL

kafgres : Kafka protocol broker embedded in PostgreSQL

Overview

ID Extension Package Version Category License Language
9440 kafgres kafgres 0.3.0 SIM Elastic-2.0 Rust
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--sLd-- No Yes Yes Yes no no
PGSTY targets PG16; requires preload and broker readiness before topic SQL; segment logs need separate replication and archiving.

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT PIGSTY 0.3.0 18 17 16 15 14 kafgres -
RPM PIGSTY 0.3.0 18 17 16 15 14 kafgres_$v -
DEB PIGSTY 0.3.0 18 17 16 15 14 postgresql-$v-kafgres -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64 N/A N/A PIGSTY 0.3.0 N/A N/A
el8.aarch64 N/A N/A PIGSTY 0.3.0 N/A N/A
el9.x86_64 N/A N/A PIGSTY 0.3.0 N/A N/A
el9.aarch64 N/A N/A PIGSTY 0.3.0 N/A N/A
el10.x86_64 N/A N/A PIGSTY 0.3.0 N/A N/A
el10.aarch64 N/A N/A PIGSTY 0.3.0 N/A N/A
d12.x86_64 N/A N/A PIGSTY 0.3.0 N/A N/A
d12.aarch64 N/A N/A PIGSTY 0.3.0 N/A N/A
d13.x86_64 N/A N/A PIGSTY 0.3.0 N/A N/A
d13.aarch64 N/A N/A PIGSTY 0.3.0 N/A N/A
u22.x86_64 N/A N/A PIGSTY 0.3.0 N/A N/A
u22.aarch64 N/A N/A PIGSTY 0.3.0 N/A N/A
u24.x86_64 N/A N/A PIGSTY 0.3.0 N/A N/A
u24.aarch64 N/A N/A PIGSTY 0.3.0 N/A N/A
u26.x86_64 N/A N/A PIGSTY 0.3.0 N/A N/A
u26.aarch64 N/A N/A PIGSTY 0.3.0 N/A N/A
Package Version OS ORG SIZE File URL
kafgres_16 0.3.0 el8.x86_64 pigsty 2.4 MiB kafgres_16-0.3.0-1PGSTY.el8.x86_64.rpm
kafgres_16 0.3.0 el8.aarch64 pigsty 2.0 MiB kafgres_16-0.3.0-1PGSTY.el8.aarch64.rpm
kafgres_16 0.3.0 el9.x86_64 pigsty 2.4 MiB kafgres_16-0.3.0-1PGSTY.el9.x86_64.rpm
kafgres_16 0.3.0 el9.aarch64 pigsty 2.1 MiB kafgres_16-0.3.0-1PGSTY.el9.aarch64.rpm
kafgres_16 0.3.0 el10.x86_64 pigsty 2.4 MiB kafgres_16-0.3.0-1PGSTY.el10.x86_64.rpm
kafgres_16 0.3.0 el10.aarch64 pigsty 2.1 MiB kafgres_16-0.3.0-1PGSTY.el10.aarch64.rpm
postgresql-16-kafgres 0.3.0 d12.x86_64 pigsty 2.1 MiB postgresql-16-kafgres_0.3.0-1PGSTY~bookworm_amd64.deb
postgresql-16-kafgres 0.3.0 d12.aarch64 pigsty 1.7 MiB postgresql-16-kafgres_0.3.0-1PGSTY~bookworm_arm64.deb
postgresql-16-kafgres 0.3.0 d13.x86_64 pigsty 2.1 MiB postgresql-16-kafgres_0.3.0-1PGSTY~trixie_amd64.deb
postgresql-16-kafgres 0.3.0 d13.aarch64 pigsty 1.7 MiB postgresql-16-kafgres_0.3.0-1PGSTY~trixie_arm64.deb
postgresql-16-kafgres 0.3.0 u22.x86_64 pigsty 2.3 MiB postgresql-16-kafgres_0.3.0-1PGSTY~jammy_amd64.deb
postgresql-16-kafgres 0.3.0 u22.aarch64 pigsty 2.0 MiB postgresql-16-kafgres_0.3.0-1PGSTY~jammy_arm64.deb
postgresql-16-kafgres 0.3.0 u24.x86_64 pigsty 2.3 MiB postgresql-16-kafgres_0.3.0-1PGSTY~noble_amd64.deb
postgresql-16-kafgres 0.3.0 u24.aarch64 pigsty 2.0 MiB postgresql-16-kafgres_0.3.0-1PGSTY~noble_arm64.deb
postgresql-16-kafgres 0.3.0 u26.x86_64 pigsty 2.3 MiB postgresql-16-kafgres_0.3.0-1PGSTY~resolute_amd64.deb
postgresql-16-kafgres 0.3.0 u26.aarch64 pigsty 2.0 MiB postgresql-16-kafgres_0.3.0-1PGSTY~resolute_arm64.deb

Source

pig build pkg kafgres;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install kafgres;		# install via package name, for the active PG version

pig install kafgres -v 16;   # install for PG 16

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'kafgres';

Create this extension with:

CREATE EXTENSION kafgres;

Usage

Sources:

kafgres embeds a Kafka protocol broker in PostgreSQL. Upstream release 0.3.0 builds and tests PostgreSQL 13–18. It needs superuser installation, shared preload and a restart. Its license is Elastic License 2.0.

Enable the broker

shared_preload_libraries = 'kafgres'
kafgres.database = 'postgres'
kafgres.bind_host = '127.0.0.1'
kafgres.advertised_host = '127.0.0.1'
kafgres.port = 9092
CREATE EXTENSION kafgres;
SELECT kafgres_create_topic('demo', 1);
BEGIN;
SELECT kafgres_produce('demo', 'key', 'value');
COMMIT;
SELECT * FROM kafgres_partition_offsets('demo');

Kafka clients connect to the configured broker port. SQL production participates in the caller’s transaction. Configure TLS, authentication and ACLs before exposing the listener beyond a trusted local environment.

Storage and CDC

kafgres.storage_engine defaults to segment; its log uses separate files and requires the extension’s replication and archive procedures. Configure kafgres.segment_archive_command and monitor kafgres_archive_status() before relying on segment retention and recovery. Ordinary PostgreSQL WAL/PITR does not cover the entire segment log. The table engine keeps its log in PostgreSQL tables; changing engines does not migrate existing records.

CDC additionally requires wal_level = logical; some PostgreSQL builds also require an output_plugin_libraries allowlist. Version 0.3.0 supports SQL CDC mappings with projection and filtering. Review the mapping and recovery procedures before deployment; the tagged CI matrix and release artifacts cover PostgreSQL 13–18.

Durability Settings

Version 0.3.0 defaults kafgres.fsync_before_ack to on and kafgres.relaxed_produce_commit to off. Relaxing the first can lose acknowledged segment records on a power failure; relaxing the second can lose the newest idempotent-producer state after a crash and permit duplicates after retries. These settings have narrower scope than transactional SQL production and do not apply uniformly to the table engine. Preserve the strict defaults until the durability tradeoff is deliberate.

0.3.0 Upgrade

Install the matching 0.3.0 library, restart, then run ALTER EXTENSION kafgres UPDATE in the broker database. The SQL update restricts administrative-function grants and pins the producer search path. The first segment-engine start removes old-format timestamp indexes from 0.2.0; old segments remain readable by scanning, while new segments receive current indexes.