PostgreSQL supports data consistency by using the popular Multiversion Concurrency Control (MVCC) model. It allows each transaction to see a stable snapshot of data as it was some time ago, regardless of concurrent changes made by other transactions.
Shardman adapts this model for distributed systems. The model
provides strong ACID guarantees, which actually means implementing Atomicity and Isolation
in the distributed case. Durability is already handled by PostgreSQL,
and consistency relates to business logic. Currently Shardman
only supports distributed REPEATABLE READ isolation level, which protects
from most of the anomalies. It is implemented using the technique known as Global Snapshots.
This technique provides isolation with the decentralized Clock-SI algorithm and relies on
the two-phase commit (2PC) protocol for atomicity. Internally, physical time is used for
snapshots across nodes, so it must be synchronized at least with NTP services. In addition,
2PC is a blocking protocol and in case of coordinator failure, the transaction may hang
until the coordinator is restored. It is recommended that you enable replication for high
availability of nodes, so such transactions could quickly resolved by built-in monitoring
tools.
The use of Global Snapshots is turned off by default, in which case isolation levels work as usual for single-node transactions, but multi-node transactions may see updates on remote nodes within a single statement or part of a committed distributed transaction. To enable Global Snapshots, use the enable_csn_snapshot option. For other related parameters, see Reference.
Note that Shardman provides a causal distributed consistency level for sticky client sessions, when a client is connected to a single node during the session. This level provides the same consistency guaranties as for a single PostgreSQL node if you ensure that load balancers route the same client to the same node. Otherwise, the consistent prefix reads guarantee is only supported. The sequence of writes is causally ordered, but it may not contain the most recent ones, including writes from the same client.