Conflict resolution and standby failover
Choose deterministic conflict rules for bidirectional Spock replication, monitor apply workers, and rehearse standby promotion.
Choose conflict arbitration rules
Asynchronous multi-master replication allows two nodes to commit writes to the same row before replicating to each other. Before adding a table to a spock replication set, configure track_commit_timestamp = on on every node and match each table column pattern to a deterministic conflict rule:
- Last-update-wins (
last_update_wins): Resolves concurrentINSERT/UPDATEconflicts using commit timestamps; Mimus kernel layers200/201preserve surviving subtransaction commit timestamps insideCOMMITWAL so physical standbys see identical timestamps. - Delta-apply (
spock.delta_apply): For numeric counters and balances, enablelog_old_value = trueanddelta_apply_function = spock.delta_applyon the column so concurrent increments and decrements commute cleanly. - Distributed IDs: Avoid colliding
SERIALsequences across writable nodes by assigning disjoint sequence ranges, UUIDs, or the pgEdge Snowflake extension.
Monitor subscriptions and conflict logs
Check subscription state, replication slot lag, and recorded conflict history on every writable node:
See pgEdge conflict operations for detailed diagnostics.
Rehearse physical standby promotion
When pairing Spock logical nodes with local physical HA standbys:
- Ensure every physical standby runs a Mimus kernel built through layer
201(or full401) so it can replay Spock’s customCOMMITWAL records generated during subtransaction conflict resolution; stock community PostgreSQL binaries cannot replay those records. - Synchronize logical replication slot positions (
sync_replication_slotsor controlled slot failover) and encryption key providers on standbys before rehearsing promotion; see pgEdge recovery boundaries.
