Multiversion Concurrency Control - Example

Example

At Time = "t1", the state of a database could be:

Time Object 1 Object 2
t1 "Hello" "Bar"
t0 "Foo" "Bar"

This indicates that the current set of this database (perhaps a key-value store database) is Object 1="Hello", Object 2="Bar". Previously, Object 1 was "Foo" but that value has been superseded. It is not deleted because the database holds multiple versions, but it will be deleted later.

If a long running transaction starts a read operation, it will operate at transaction "t1" and see this state. If there is a concurrent update (during that long-running read transaction) which deletes Object 2 and adds Object 3="Foo-Bar", the database state will look like:

Time Object 1 Object 2 Object 3
t2 "Hello" (deleted) "Foo-Bar"
t1 "Hello" "Bar"
t0 "Foo" "Bar"

Now there is a new version as of transaction ID "t2". Note, critically, that the long-running read transaction still has access to a coherent snapshot of the system at "t1", even though the write transaction added data as of "t2", so the read transaction is able to run in isolation from the update transaction that created the "t2" values. This is how MVCC allows isolated, ACID reads without any locks. (Note, however, that the write transaction does need to use locks.)

Read more about this topic:  Multiversion Concurrency Control

Famous quotes containing the word example:

    Our intellect is not the most subtle, the most powerful, the most appropriate, instrument for revealing the truth. It is life that, little by little, example by example, permits us to see that what is most important to our heart, or to our mind, is learned not by reasoning but through other agencies. Then it is that the intellect, observing their superiority, abdicates its control to them upon reasoned grounds and agrees to become their collaborator and lackey.
    Marcel Proust (1871–1922)