On the publisher, set wal_level=logical in postgresql.conf and reload; confirm with SHOW wal_level
Create a publication: CREATE PUBLICATION my_pub FOR TABLE orders, customers; (or FOR ALL TABLES)
On the subscriber, create the subscription using a DSN that stores credentials in .pgpass or PGPASSFILE rather than inline: CREATE SUBSCRIPTION my_sub CONNECTION 'host=primary dbname=app user=replicator' PUBLICATION my_pub
Monitor replication lag with: SELECT slot_name, confirmed_flush_lsn, pg_wal_lsn_diff(pg_current_wal_lsn(), confirmed_flush_lsn) AS lag_bytes FROM pg_replication_slots
Set max_slot_wal_keep_size (defaults to -1, unlimited) to cap WAL retained by inactive slots so disk does not fill up
Drop unused slots promptly with SELECT pg_drop_replication_slot('slot_name') to prevent unbounded WAL accumulation
Known gotchas
max_slot_wal_keep_size defaults to -1 (no limit), so a lagging or orphaned slot will retain WAL indefinitely and can exhaust disk; set a safe limit and alert on pg_replication_slots.inactive
Logical replication does not replicate DDL, sequences, or large objects; schema changes must be applied on the subscriber manually before altering the publisher table
The subscription user needs REPLICATION privilege and SELECT on published tables; missing grants cause the apply worker to error silently at first sync
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp