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
fix(storage): stop workspace ledger locks from deadlocking on FK key-share (#7187)
* fix(storage): stop workspace ledger locks from deadlocking on FK key-share
Workspace storage accounting locked the workspace, organization, and
user_stats rows with SELECT ... FOR UPDATE. Those rows are foreign-key
parents, so a transaction that has already written a billable child row
holds an implicit FOR KEY SHARE on the parent, and the stronger lock is
an upgrade that two concurrent uploads take on each other.
Take FOR NO KEY UPDATE instead. It does not conflict with FOR KEY SHARE,
still conflicts with itself, and is the lock a plain UPDATE of these
non-key counters takes anyway, so the ledgers stay serialized.
* test(storage): cover both payer kinds in the ledger lock-mode assertions
The lock-mode regression tests only exercised the organization payer, so
the user_stats lock branches were never asserted and a revert of just
those would have passed. Parameterize both tests over both payer kinds
and assert the exact call list, so a lock that stops being taken at all
fails too.
* docs(table): correct the stale FOR UPDATE reference in the quota note
The advisory quota check describes createTable's count as the authoritative
FOR UPDATE read; that lock is now FOR NO KEY UPDATE.
0 commit comments