Consistency and Replication CSCI 69004900 DataCentric Consistency Models

  • Slides: 14
Download presentation
Consistency and Replication CSCI 6900/4900

Consistency and Replication CSCI 6900/4900

Data-Centric Consistency Models The general organization of a logical data store, physically distributed and

Data-Centric Consistency Models The general organization of a logical data store, physically distributed and replicated across multiple processes.

Consistency Models • Contract between processes and data store • If the processes play

Consistency Models • Contract between processes and data store • If the processes play by certain rules the store promises to work correctly – Data store guarantees certain properties on the data items stored – Example: A read on a data item would always return the value showing the most recent write • Several data consistency models – Strict consistency, sequential consistency, causal consistency, FIFO consistency

Strict Consistency • Most stringent consistency model “Any read on a data item x

Strict Consistency • Most stringent consistency model “Any read on a data item x returns a value corresponding to the result of the most recent write on x” • Natural and obvious • Uniprocessor systems guarantee strict consistency • Implicitly assumes the existence of absolute global time

Strict Consistency - Illustration Behavior of two processes, operating on the same data item.

Strict Consistency - Illustration Behavior of two processes, operating on the same data item. • A strictly consistent store. • A store that is not strictly consistent.

Problems with Strict Consistency • Strict consistency poses serious problems for systems with multiple

Problems with Strict Consistency • Strict consistency poses serious problems for systems with multiple machines • Example – Two machines A & B located in different continents & data item x is stored on B. – A performs a read at T 1 and immediately after B performs a write at T 2 – If T 2 – T 1 is very small, the write would have completed before T 1 arrives. Thus T 1 reads the new value • Problem arises because strict consistency relies on absolute global time – Impossible to assign unique time stamps corresponding to actual global time – Locks do not solve the problem

Sequential Consistency • Slightly weaker consistency model “The result of any execution is the

Sequential Consistency • Slightly weaker consistency model “The result of any execution is the same as if the (read & write operations by all the processes on the data store were executed in some sequential order and the operations of each individual process appear in this sequence in the order specified by its program” • Any valid interleaving of read and write operations • All processes should see the same interleaving of operations • Time does not play a role in this model

Sequential Consistency - Example a) b) A sequentially consistent data store. A data store

Sequential Consistency - Example a) b) A sequentially consistent data store. A data store that is not sequentially consistent.

Linearizability • Weaker than strict consistency but stronger than sequential consistency • Operation receive

Linearizability • Weaker than strict consistency but stronger than sequential consistency • Operation receive a timestamp from a globally available clock, but the clock has finite precision “The result of any execution is the same as if the (read and write) operations by all the processes on the data store were executed in some sequential order and the operations of each individual process appear in this sequence in the order specified by its program. In addition if ts. OP 1(x) < ts. OP 2(y) then OP(1) should precede OP 2 in this sequence. • A linearizable data store is also sequential

Validity in Sequential Consistency Process P 1 Process P 2 Process P 3 x

Validity in Sequential Consistency Process P 1 Process P 2 Process P 3 x = 1; print ( y, z); y = 1; print (x, z); z = 1; print (x, y); Three concurrently executing processes.

Validity in Sequential Consistency x = 1; print ((y, z); y = 1; print

Validity in Sequential Consistency x = 1; print ((y, z); y = 1; print (x, z); z = 1; print (x, y); x = 1; y = 1; print (x, z); print(y, z); z = 1; print (x, y); y = 1; z = 1; print (x, y); print (x, z); x = 1; print (y, z); y = 1; x = 1; z = 1; print (x, z); print (y, z); print (x, y); Prints: 001011 Prints: 101011 Prints: 010111 Prints: 111111 Signature: 001011 (a) Signature: 101011 (b) Signature: 110101 (c) Signature: 111111 (d) Four valid execution sequences for the processes of the previous slide. The vertical axis is time.

Causal Consistency • Weaker than sequential consistency • Differentiates between causally related events and

Causal Consistency • Weaker than sequential consistency • Differentiates between causally related events and those that are not • Example: Process P 1 writes x. Process P 2 reads x and writes y. Reading of x and writing on y are potentially causally related. However two independent writes are not causally related “Writes that are potentially casually related must be seen by all processes in the same order. Concurrent writes may be seen in a different order on different machines. ”

Casual Consistency - Example This sequence is allowed with a casually-consistent store, but not

Casual Consistency - Example This sequence is allowed with a casually-consistent store, but not with sequentially or strictly consistent store.

Casual Consistency- Example [Contd. ] a) b) A violation of a casually-consistent store. A

Casual Consistency- Example [Contd. ] a) b) A violation of a casually-consistent store. A correct sequence of events in a casually-consistent store.