JEPSEN

P0 (Dirty Write)

Phenomenon P0, or Dirty Write, occurs when one transaction writes over another transaction before that transaction has completed. Specifically, transaction Ti writes some version xi, and a different transaction Tj writes the next version of x. Then both transactions go on to commit, or abort, in any order.

P0 is defined in terms of a total order of events. In a distributed system, this order may not meaningfully exist.

Surprisingly, P0 is allowed by the ANSI SQL definition of Read Uncommitted, Read Committed, and Repeatable Read. In the late 1990s, Berenson and Adya argued this was accidental; the standard’s authors likely intended to prevent it. However, the standard’s language remains un-changed.

Formally

Berenson et al defined P0 in their Snapshot Isolation paper:

A dirty write occurs when transaction T1 writes x, then T2 writes x prior to T1’s abort or commit:

  • P0: w1[x] … w2[x] … ((c1 or a1) and (c2 or a2) in any order)

See Also

Adya’s G0 (Write Cycle) generalizes the concept of write isolation to any number of transactions whose writes interfere with each other. G0 is also more precise: proscribing P0 rules out some Serializable histories, whereas proscribing G0 does not.