Search code examples
distributed-computing

What is the difference between serializability and linearizability?


I am very confused between these two consistency models. Please give some timeline examples along with explanation. http://en.wikipedia.org/wiki/Consistency_model


Solution

  • It was hard to find information about this subject. However, At some point I found a statement that explained it clearly:

    • Linearizability gives isolation at the level of operations, while Serializability gives isolation at the level of transactions.

    (summarized from the in-depth description found here)

    As an example:

    enter image description here

    Here, A, B and C are three different transactions running at the same time. r(varname) means that the current transaction is accessing the value inside varname, and w(varname) means that the current transaction is writing a certain value in varname.

    Now, to create a linearized history of these events, we have to make sure that no two operations are happening at the same time. An operation that has started while another operation already started should appear behind the first operation.

    In this case:

    Log1: A.r(x), B.r(X), B.r(Y), A.w(X), C.r(Y)
    

    To create a Serialized history of these events, one has to separate all the operations of the transactions A, B and C so there are no interleaved operations from other transactions.

    From our example this could result in:

    Log2: A.r(x), A.w(x), B.r(X), B.r(Y), C.r(Y)