You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Update methods in the storage later take the resource and an expected version as parameters. For example:
UpdateActor(ctx context.Context, actor *Actor, expectedVersion int64) (*Actor, error)
The contract is that the mutable fields are copied over from actor iff the expectedVersion matches the value in the DB. This is checked within a single tx.
A much simpler (and expressive) API would be one that takes a mutate closure and performs a transactional read-modify-write. For example:
I think we need to let the storage layer be atomic. To my eyes that looks something like:
RPC layer UpdateActor(newActor)
Create a callback
Call storage layer UpdateActor(newActor, callback)
Open txn
Get current value from DB
Call callback(new, old)
6a) Check UID precondition IFF it was specified
6b) Check version IFF it was specified
6c) Apply changes to in-memory state
Commit
Reacted by Julian Gutierrez Oschmann and Luiz Oliveira
Activity
thockin commentedon Aug 9, 2026
I think we need to let the storage layer be atomic. To my eyes that looks something like:
RPC layer UpdateActor(newActor)
Create a callback
Call storage layer UpdateActor(newActor, callback)
Open txn
Get current value from DB
Call callback(new, old)
6a) Check UID precondition IFF it was specified
6b) Check version IFF it was specified
6c) Apply changes to in-memory state
Commit
Fix toctou race in UpdateActor (#829)
Fix TOCTOU race in UpdateActorSnapshotTag (#854)
laoj2 commentedon Aug 18, 2026
Closing this issue. The remaining PR (#1014) is more closely related to #954