Uh oh!
There was an error while loading. Please reload this page.
feat(db) resource version cas - #1292
Conversation
30e8540 to
46c93c3CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
46c93c3 to
4931e83Comparederekwaynecarr
commented
May 14, 2026
@johntmyers ptal. updated per prior feedback, also updated all proto paths that required CAS enablement. the recently merged draft chunk work is not covered right now, i would like to leave that as a follow-on. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
4456536 to
d65c359Comparederekwaynecarr
commented
May 16, 2026
All prior comments are resolved.
|
derekwaynecarr
commented
May 16, 2026
/ok to test d65c359 |
derekwaynecarr
commented
May 16, 2026
failure due to flaky test, fix #1417 |
76a5ab8 to
afdf64fComparederekwaynecarr
commented
May 18, 2026
/ok to test afdf64f |
Add resource_version-based optimistic concurrency control to the persistence layer. Every write now requires an explicit WriteCondition (MustCreate or MatchResourceVersion), enforced at compile time by gating unconditional put/put_message behind #[cfg(test)]. - Add WriteCondition enum and put_if for conditional writes - Add update_message_cas for atomic read-modify-write operations - Add list_messages/list_messages_with_selector helpers that hydrate resource_version from authoritative DB rows - Convert all production write paths to CAS-aware methods - Gate put/put_message behind #[cfg(test)] to prevent non-CAS writes - Use structured PersistenceError::UniqueViolation matching instead of string matching for duplicate detection - Hydrate resource_version from WriteResult directly on creates, eliminating unnecessary read-after-write round trips Signed-off-by: Derek Carr <decarr@redhat.com>
afdf64f to
0a09cacComparederekwaynecarr
commented
May 18, 2026
/ok to test 0a09cac |
Uh oh!
There was an error while loading. Please reload this page.
Summary
Add Compare-And-Swap (CAS) infrastructure for safe concurrent object mutations
and migrate critical paths to use it. This prevents lost updates in HA
deployments with multiple gateway replicas.
Core infrastructure:
Migrations:
Database migrations backfill existing rows with resource_version = 1.
CAS updates increment atomically: resource_version = resource_version + 1.
gRPC handlers map PersistenceError::Conflict to ABORTED status code
to signal clients to retry with fresh data. Server-side retries use
bounded retry (5 attempts) with fresh reads on each iteration.
Test coverage includes concurrent update scenarios and handler-level
resource_version round-trip tests.
Related Issue
Fixes#1255
Changes
Testing
mise run pre-commitpassesChecklist