red888
red888

Reputation: 31560

Is two phase commit an implementation of linearizability?

Most implementations of two-phase commit, as I understand them, require all nodes of a system to agree on the value before committing locally and only after they have all committed locally respond to the client- is this a correct understanding of 2PC?

Does this then make 2PC an implementation of the linearizable sequential consistency model?

I was thinking that because the value returned to the client will never be out of date and it's happening in real time that means it's truly linearizable right?

I never hear 2PC described as linearizable though so think there is something here I'm misunderstanding.

Upvotes: 2

Views: 378

Answers (1)

Drathier
Drathier

Reputation: 14519

It doesn't have to be, and there are many better algorithms that survive crash failures (which 2PC doesn't). That said, you can use two phase commit to help implement linearizability or strong serializability.

The "value returned to the client will never be out of date and it's happening in real time" statement completely ignores the presence of caches and queues, which easily allow you to read from the past or write to the future, so watch out for that.

Upvotes: 2

Related Questions