CAP theorem names an unavoidable distributed-systems tradeoff: consistency means reads return the latest data or error; availability means every request receives a response, possibly not the latest data; partition tolerance means operating while messages are dropped or delayed. A system cannot guarantee all three simultaneously. section 5.5
The practical mistake is treating bidirectional replication between independent PostgreSQL instances as a simple route to a highly available multi-master database. PostgreSQL replication uses a shared-nothing design, so independent nodes must communicate through replication connections; delays, dropped messages, and concurrent writes make the tradeoffs concrete. section 5.5
Under a network partition, choose deliberately between:
- Consistency: reject or error rather than return data that may not be current. section 5.5
- Availability: answer every request even though the response may not reflect the most recent data. section 5.5
PACELC extends the decision beyond failures: during a partition, choose availability or consistency; otherwise, choose between latency and loss of consistency. This matters for databases expected to stay online most of the time, not only during an outage. section 5.5
Two-way logical replication is not conflict handling
Two independent nodes can publish and subscribe to each other, then appear to replicate inserts successfully. But a locally generated identity value can collide with an already replicated primary key, producing a duplicate-key error. Schema changes can also leave a target missing a replicated column, causing the logical-replication worker to exit. Replication wiring alone does not resolve distributed conflicts or coordinate schema changes. section 5.5
Figure 5.2 Logical replication in both directions
Use the topology diagram to inspect the two independent replication directions that make a seemingly simple multi-master setup vulnerable to distributed coordination problems. section 5.5
For production multi-master use, prefer an established multi-master solution rather than assembling one from unidirectional logical replication. Homemade distributed systems need a narrowly focused scope and must account for distributed serialization anomalies plus CAP and PACELC tradeoffs. section 5.7



