Skip to content

Add conflict-compatible commutative transaction merges - #6

Draft
xav-db wants to merge 4 commits into
mainfrom
codex/commutative-merge
Draft

Add conflict-compatible commutative transaction merges#6
xav-db wants to merge 4 commits into
mainfrom
codex/commutative-merge

Conversation

@xav-db

@xav-db xav-db commented Aug 3, 2026

Copy link
Copy Markdown
Member

Summary

  • Add the opt-in DbTransaction::merge_commutative API, with the inherent Rust method as the canonical contract and matching trait and UniFFI guidance.
  • Classify transaction writes as exclusive or commutative merges and omit same-key write/write conflicts only when both transactions contain exclusively commutative merges for that key.
  • Preserve serializable point/range read dependencies, mixed-operation conflict behavior, ordinary merge semantics, and unmark_write.
  • Cover compatible merges, ordinary merge/put/delete conflicts, mixed writes, repeated classification, SSI reads, and existing untracked-write behavior.

Why

SlateDB currently treats blind merge-only updates like exclusive writes. That forces retries on hot keys even when the configured merge operator is order-independent, such as counters, set union, or bitmap union.

The new API makes that stronger algebraic contract explicit. Both operands remain in the normal atomic write batch; only conflict metadata changes, and callers remain responsible for commutativity.

Impact

Applications can opt compatible same-key merge operands out of unnecessary write/write conflicts without weakening read tracking or changing persistence. Existing callers and ordinary merges retain their current conservative behavior.

Validation

  • All-feature workspace tests and doctests
  • Clippy with warnings denied
  • Rustfmt check
  • Targeted branch tests for every write-classification path

cargo llvm-cov executed the targeted tests successfully, but its final report exporter terminated with SIGSEGV in the local environment.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant