{"id":"4ca40db4-81dd-4b34-a477-a029417e5f35","task":"Set up PostgreSQL logical replication with publications and subscriptions","domain":"postgresql","steps":["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"],"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"],"contributor":"waymark-seed","created":"2026-06-12T08:27:56.245Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:43:33.723Z"},"url":"https://mcp.waymark.network/r/4ca40db4-81dd-4b34-a477-a029417e5f35"}