Building a Logical Replication System
summary
A custom logical replication system called Connemara rebuilds each source schema and streams changes into a data lake by combining a consistent pg_dump snapshot (using a replication slot and exported snapshot), a lightweight daemon that consumes a wal2json change stream, and a multi-threaded replayer that reconstructs SQL and applies changes. It runs in production (peaks ~70,000 changes/sec input, ~15,000 changes/sec replay), supports selective DDL/DML propagation and schema remapping, and is intended to be open sourced.
AI-written summary · about
chapters (18)
- 0:00Introduction
- 1:03Why logical replication
- 3:09Existing solution challenges
- 5:15Building our own
- 5:37PostgreSQL logical basics
- 7:22Key components setup
- 11:53Backup and snapshot
- 13:58Schema restoration issues
- 16:48Rewriting schema with pgloader
- 19:14Initial setup summary
- 19:56Streaming replication process
- 21:43Handling large transactions
- 22:45Replayer details
- 24:13DDL propagation
- 25:57System monitoring
- 27:23Future improvements
- 28:27Challenges
- 31:18Project learnings
