consistency, isolation, durability) is a
different kind of consistency guarantee. In ACID, consistency relates to the
guarantee that when a transaction is
finished the database is in a consistent
state; for example, when transferring
money from one account to another
the total amount held in both accounts
should not change. In ACID-based systems, this kind of consistency is often
the responsibility of the developer writing the transaction but can be assisted
by the database managing integrity
constraints.
consistency—client and server
There are two ways of looking at consistency. One is from the developer/client
point of view: how they observe data
updates. The other is from the server
side: how updates flow through the system and what guarantees systems can
give with respect to updates.
The components for the client side
include:
˲ A storage system. For the moment
we’ll treat it as a black box, but one
should assume that under the covers it
is something of large scale and highly
distributed, and that it is built to guarantee durability and availability.
˲ Process A. This is a process that
writes to and reads from the storage
system.
˲ Process B and C. These two processes are independent of process A and
write to and read from the storage system. It is irrelevant whether these are
really processes or threads within the
same process; what is important is that
they are independent and need to communicate to share information.
Client-side consistency has to do
with how and when observers (in this
case the processes A, B, or C) see updates made to a data object in the stor-
age systems. In the following examples
illustrating the different types of consistency, process A has made an update
to a data object:
˲ Strong consistency. After the update
completes, any subsequent access (by A,
B, or C) will return the updated value.
˲ Weak consistency. The system does
not guarantee that subsequent accesses will return the updated value. A
number of conditions need to be met
before the value will be returned. The
period between the update and the moment when it is guaranteed that any observer will always see the updated value
is dubbed the inconsistency window.
˲ Eventual consistency. This is a specific form of weak consistency; the
storage system guarantees that if no
new updates are made to the object,
eventually all accesses will return the
last updated value. If no failures occur,
the maximum size of the inconsistency
window can be determined based on
factors such as communication delays,
the load on the system, and the number of replicas involved in the replication scheme. The most popular system
that implements eventual consistency
is the domain name system (DNS).
Updates to a name are distributed according to a configured pattern and
in combination with time-controlled
caches; eventually, all clients will see
the update.
The eventual consistency model has
a number of variations that are important to consider:
˲ Causal consistency. If process A has
communicated to process B that it has
updated a data item, a subsequent access by process B will return the updated value, and a write is guaranteed to
supersede the earlier write. Access by
process C that has no causal relationship to process A is subject to the normal eventual consistency rules.
˲ Read-your-writes consistency. This
is an important model where process
A, after having updated a data item,
always accesses the updated value
and never sees an older value. This is a
special case of the causal consistency
model.
˲ Session consistency. This is a practical version of the previous model,
where a process accesses the storage
system in the context of a session. As
long as the session exists, the system
guarantees read-your-writes consisten-
cy. If the session terminates because of
a certain failure scenario, a new session
must be created and the guarantees do
not overlap the sessions.
˲ Monotonic read consistency. If a process has seen a particular value for the
object, any subsequent accesses will
never return any previous values.
˲ Monotonic write consistency. In this
case, the system guarantees to serialize the writes by the same process. Systems that do not guarantee this level of
consistency are notoriously difficult to
program.
A number of these properties can
be combined. For example, one can
get monotonic reads combined with
session-level consistency. From a
practical point of view these two properties (monotonic reads and read-your-writes) are most desirable in an
eventual consistency system, but not
always required. These two properties
make it simpler for developers to build
applications, while allowing the storage system to relax consistency and
provide high availability.
As you can see from these variations,
quite a few different scenarios are possible. It depends on the particular applications whether or not one can deal
with the consequences.
Eventual consistency is not some
esoteric property of extreme distributed systems. Many modern RDBMSs
(relational database management systems) that provide primary-backup
reliability implement their replication
techniques in both synchronous and
asynchronous modes. In synchronous
mode the replica update is part of the
transaction. In asynchronous mode
the updates arrive at the backup in a
delayed manner, often through log
shipping. In the latter mode if the primary fails before the logs are shipped,