Concurrent writes with optimistic concurrency control

video locked
Enroll to watch

8 mins

Chapters
About
Discussion0
Notes
Be the first to start a conversation!

Optimistic concurrency control lets two writers change the same group in Zanzibar without a lock: each changes a copy, and the first commit wins.

Tuhin adds a member with a zookie of a hundred while Pooja deletes one with a zookie of 50. Zanzibar does not use the zookie to order them.

  1. A copy. Each writer copies the user set at version V1 and changes the copy.
  2. A commit. Pooja commits first, and the group is at V2.
  3. A rejection. Tuhin's change has V1 as its base and V2 is the current version, so Zanzibar rejects it.
  4. A retry. Tuhin takes V2, adds member 555 again and commits V3.

A lock is the pessimistic choice. An exclusive lock makes every read wait, and the holder can die with it. Zanzibar is highly available and read heavy, so it does not lock.

A third writer can commit before the retry, and the retry is rejected again. A copy and a commit take milliseconds, so a change that takes long keeps failing.