{
  "slug": "lost-update",
  "term": "Lost update",
  "aliases": [
    "Lost update anomaly",
    "P4 lost update"
  ],
  "definition": "A lost update occurs when a write based on an earlier read overwrites another actor's intervening update to the same data item.",
  "note": "Berenson et al. describe this as phenomenon P4. Write skew is different: transactions can change different items while jointly violating a constraint. [berenson-lost-update]\n\nA database can serialize individual statements correctly while an application still loses an increment across separate read and write transactions. Hesela's native SQLite WAL experiment has two callers read zero and later each write one; both writes succeed but the final counter is one. This is not a failure of SQLite transaction isolation. [sqlite-transactions] [hesela-evidence]\n\nAn UPDATE that computes value=value+1 inside the statement preserves both increments in this one-row experiment. A version-qualified UPDATE instead rejects the second stale request with zero affected rows and no SQL error. That rejection does not complete the requested increment. Engineering condition: every participating writer must advance a version that is not reused; the database does not enforce this application protocol automatically. [sqlite-update] [hesela-evidence]\n\nWith both read transactions kept open, the WAL control rejects promotion of the stale snapshot with SQLITE_BUSY_SNAPSHOT (517), then explicitly rolls back; it does not retry. A storage-stack lost write is a different problem: completion was reported but the intended storage update is absent. No crash or storage fault is injected here. [sqlite-isolation] [sqlite-busy-result] [hesela-lost-write]\n\nRetry implication, not another measured schedule: restart the read-compute-write operation from a fresh read; do not replay an old literal after rollback. A zero-row guard must be handled as a conflict. [sqlite-isolation] [sqlite-update]",
  "related": [
    "lost-write",
    "compare-and-swap",
    "write-skew",
    "serializability",
    "sqlite-busy-snapshot",
    "read-committed-isolation"
  ],
  "status": "unknown",
  "advantages": [],
  "limitations": [],
  "supersedes": [],
  "supersededBy": [],
  "firstSeen": null,
  "lastSeen": null,
  "updated": "2026-11-13",
  "citations": [
    {
      "id": "berenson-lost-update",
      "title": "Berenson et al. A Critique of ANSI SQL Isolation Levels. SIGMOD 1995, sections 4.1 (P4) and 4.2 (A5B).",
      "url": "https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/tr-95-51.pdf",
      "accessed": "2026-11-13"
    },
    {
      "id": "sqlite-transactions",
      "title": "SQLite Transaction: sections 2 and 2.3, implicit transactions and completed statements.",
      "url": "https://www.sqlite.org/lang_transaction.html",
      "accessed": "2026-11-13"
    },
    {
      "id": "sqlite-update",
      "title": "SQLite UPDATE: section 2, row predicates and assignment expressions.",
      "url": "https://www.sqlite.org/lang_update.html",
      "accessed": "2026-11-13"
    },
    {
      "id": "sqlite-isolation",
      "title": "SQLite Isolation: WAL snapshot isolation and SQLITE_BUSY_SNAPSHOT.",
      "url": "https://www.sqlite.org/isolation.html",
      "accessed": "2026-11-13"
    },
    {
      "id": "sqlite-busy-result",
      "title": "SQLite result codes: SQLITE_BUSY_SNAPSHOT (517).",
      "url": "https://www.sqlite.org/rescode.html#busy_snapshot",
      "accessed": "2026-11-13"
    },
    {
      "id": "hesela-evidence",
      "title": "Hesela: native SQLite lost-update schedules, source, method and results.",
      "url": "https://hesela.dev/research/lost-update/README.md",
      "accessed": "2026-11-13"
    },
    {
      "id": "hesela-lost-write",
      "title": "Hesela: Lost write, storage-stack completion versus recorded data.",
      "url": "https://hesela.dev/terms/lost-write/",
      "accessed": "2026-11-13"
    }
  ],
  "provenance": [
    "Primary-source synthesis and a native, deterministic SQLite 3.45.1 experiment. Four prescribed schedules, not a benchmark, prevalence estimate, crash test or general isolation-conformance test."
  ]
}
