Postgres sync replication, in plain words
How CoyoteDB uses synchronous Postgres replication so a save counts only once two computers have it, and what happens with one data node left.
When CoyoteDB tells your app “saved”, it means two computers have that save, not one. This page explains what that means and when it changes.
Synchronous replication, in plain words
Replication means copying every change from the main node to the other data nodes as it happens. There are two ways to do it:
- Asynchronous: the main node says “saved” straight away and sends the change on afterwards. If the main node dies in between, that save can be lost.
- Synchronous: the main node waits until a second data node has the change before it says “saved”. If the main node dies a moment later, the save is already on another computer.
CoyoteDB uses synchronous Postgres replication: in normal running, a save counts once a second data node has it.
With three data nodes
With three data nodes, a save needs to land on two of them. If one computer is down, there are still two left, so saves keep landing on two computers and your app does not notice.
When only one data node is left
With two data nodes (with or without a witness), losing one leaves a single computer holding the data. CoyoteDB then:
- Pauses saves for about 30 seconds, in case the other computer is just briefly unreachable.
- Carries on using the one node that is left, so saves keep working.
- Shows a clear warning until the other computer is back and caught up, because until then there is no second copy of new saves.
The stricter setting
If you would rather have saves wait than run on one copy, an optional stricter setting makes them wait until a second node is back. The trade-off: your app cannot save until then.
What replication does not do
Replication copies everything, including mistakes. A deleted table is deleted on every node at once. That is why you still need backups: see Why you still need backups.
Read more: How automatic failover works, Node counts explained, How it works.