fix(server): transactional sync push; single-use refresh rotation #136
Reference in New Issue
Block a user
Delete Branch "fix/sync-auth-races"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Review findings M1 and M2 (2026-07-06 large-scale review).
M1 — sync push race.
pushran load→merge→store as three separate DB operations; two devices pushing concurrently both read the same stored payload and the second store overwrote the first merge (self-healing later thanks to the monotone merge, but the server regressed in between). The whole cycle — including the leaderboard conditional update — now runs in a single transaction. Also fixes the leaderboard helper's stale docstring (claimed one conditional UPDATE; was two statements).M2 — refresh rotation not single-use under concurrency. The SELECT-then-DELETE sequence let two concurrent refreshes both succeed with the same token. The rotation now gates on
rows_affected == 1from the DELETE itself (the SELECT precheck is removed —rows_affected == 0covers never-existed, deleted-account, and concurrently-consumed alike). Sequential-reuse behaviour is unchanged and still covered byconsumed_refresh_token_is_rejected.Helpers were made executor-generic (
impl Executor<'_, Database = Sqlite>) sopullkeeps passing the pool whilepushpasses its transaction.Gates:
cargo clippy --workspace --all-targets -- -D warningsclean;cargo test --workspacegreen.🤖 Generated with Claude Code