Skip to content

kafgres

Kafka protocol broker embedded in PostgreSQL

Overview

PackageVersionCategoryLicenseLanguage
kafgres0.3.0SIMElastic-2.0Rust
IDExtensionBinLibLoadCreateTrustRelocSchema
9440kafgresNoYesYesYesNoNo-

PGSTY targets PG16; requires preload and broker readiness before topic SQL; segment logs need separate replication and archiving.

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY0.3.01817161514kafgres-
RPMPIGSTY0.3.01817161514kafgres_$v-
DEBPIGSTY0.3.01817161514postgresql-$v-kafgres-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64N/AN/AN/AN/A
el8.aarch64N/AN/AN/AN/A
el9.x86_64N/AN/AN/AN/A
el9.aarch64N/AN/AN/AN/A
el10.x86_64N/AN/AN/AN/A
el10.aarch64N/AN/AN/AN/A
d12.x86_64N/AN/AN/AN/A
d12.aarch64N/AN/A
PIGSTY 0.3.0
N/AN/A
d13.x86_64N/AN/A
PIGSTY 0.3.0
N/AN/A
d13.aarch64N/AN/A
PIGSTY 0.3.0
N/AN/A
u22.x86_64N/AN/A
PIGSTY 0.3.0
N/AN/A
u22.aarch64N/AN/A
PIGSTY 0.3.0
N/AN/A
u24.x86_64N/AN/A
PIGSTY 0.3.0
N/AN/A
u24.aarch64N/AN/A
PIGSTY 0.3.0
N/AN/A
u26.x86_64N/AN/AN/AN/A
u26.aarch64N/AN/A
PIGSTY 0.3.0
N/AN/A

Build

You can build the RPM / DEB packages for kafgres using pig build:

pig build pkg kafgres         # build RPM / DEB packages

Install

You can install kafgres directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

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

Install the extension using pig or apt/yum/dnf:

Install
pig install kafgres;          # Install for current active PG version
pig
pig ext install -y kafgres -v 16  # PG 16
dnf
dnf install -y kafgres_16       # PG 16
apt
apt install -y postgresql-16-kafgres   # PG 16

Preload:

shared_preload_libraries = 'kafgres';

Create Extension:

CREATE EXTENSION kafgres;

Usage

Sources:

kafgres embeds a Kafka protocol broker in PostgreSQL. Upstream release 0.3.0 targets PostgreSQL 16 using pgrx 0.16.1. 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 release artifacts target PostgreSQL 16, and Cargo feature names alone do not prove support for other majors.

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.

Was this page helpful?