Skip to content

Commit precondition on cells not changing. #8976

Open

Description

@wjones127

Some write transactions only want to commit if some other fields, such as those read, have no changed concurrently. For example, if you are computing a column y based on a column x, you don't want to commit the new values for y if column x has concurrently changed, since that would place stale values.

Add a precondition onto the commit. Should pass field ids to choose columns, and RowAddressTreemap to specify which rows. There could potentially be multiple pre-conditions. Support for passing row ids (stable row ids) is left for a future change.

let rows_covered = RowAddressTreeMap::from(100..200);
CommitBuilder::new(dataset)
   .with_precondition(Precondition::cells_unchanged([3, 4], rows_covered))
   .execute(transaction)
   .await?

Activity

  1. lichuang commented on Sep 9, 2026

    @lichuang
    Contributor

    I'd like to pick this up. Two design points to align on before opening a PR:

    1. The precondition must be a proto field on Transaction, not just a builder param.
    verify_commit_outcome detects a lost-response landing by comparing committed_transaction == *transaction byte-wise, and the read-back copy is deserialized from disk — anything not in the proto breaks that equality: a landed commit gets classified Foreign, the retry recomputes and republishes (the double-publish #9043 case 7 forbids). So Precondition { field_ids, serialized RowAddrTreeMap } goes into transaction.proto. Note this differs from #8801's CommitConfig::preconditions slot: that fits state re-derivable from the latest manifest; a declared read set only exists at staging time and must travel with the transaction.

    2. Evaluation goes in the commit loop next to check_txn, against the pinned read_version state — not gated on check_txn.
    A concurrent Delete on protected rows can be absorbed by rebase (deletion file merged, check_txn returns Ok) while the protected cells did change. Conflict compatibility and precondition validity are independent; conflict_resolver.rs stays untouched, so the #6898 differential-oracle constraint holds. This placement also gives #9043's "concurrent winner re-checks against the original dependencies" for free.

    Error semantics: reuse PrerequisiteFailed for the report, propagate as RetryableCommitConflict so execute_with_retry auto-retries for a recomputing caller (it currently only retries RetryableCommitConflict). Reject precondition × strict_overwrite at build time (strict overwrite skips the check loop).

    Plan: Phase 1 = this issue standalone (proto + builder + in-loop check + tests, no conflict_resolver.rs changes; can start on main since commit_after is merged). Phase 2 = #9043's field-disjoint Update × Update in finish. One question for that phase: is "conflict_resolver.rs must not be modified" a hard v1 freeze until #6898's actions cutover, or just a don't-fix-v1-on-the-v2-branch rule? That decides whether Phase 2 lands in v1 or waits for the v2 milestone.

  2. wjones127 commented on Sep 9, 2026

    @wjones127
    ContributorAuthor

    I would not block on transaction V2 for this. We’ll need it more immediately. Can port this to V2 quickly once it is in v1.

  3. lichuang commented on Sep 9, 2026

    @lichuang
    Contributor

    Phase 1 is in progress in v1, following the two points above — the declared read set travels with the transaction, keeping it separate from #8801's re-derivable CommitPrecondition. Phase 2 (#9043) will land in v1 as well and port to V2 after the actions cutover.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions