Serialize OAuth profile-store read-modify-write updates - #755
Serialize OAuth profile-store read-modify-write updates#755TheGreatAxios wants to merge 4 commits into
Conversation
Review · Request changesOAuth profile mutations use a filesystem lock to serialize read-modify-write updates. Findings
Notes
|
Critic · CommentThe new tests exercise common concurrent profile-store operations and stale-lock recovery. Findings
|
Implementation updateThe lock implementation now uses a per-home exclusive descriptor held through each read-modify-write operation and times out after 15 seconds without reclaiming stale or ambiguous lock files. This removes stale-owner, replacement-lock, recovery-claim, and metadata-write cleanup races. Findings addressed
Verification
|
TheGreatAxios
left a comment
There was a problem hiding this comment.
Review · Blocking
The OAuth profile store serializes read-modify-write operations with a filesystem lock.
Findings
src/auth/oauth/store.ts:140— A lock is removed solely because its mtime exceeds 10 seconds. If a live holder is suspended or delayed past that threshold, another process deletes its lock and enters the critical section; the original holder can then delete the replacement lock during cleanup. Could we use ownership-safe stale-lock recovery so a live holder cannot be displaced?src/auth/oauth/oauth.test.ts:200— The concurrent token-update assertion checks only field types, so restoring seeded token values still passes. Could the regression assert the expected refreshed token values?
GitHub CI is green, but the live-lock displacement can reintroduce overlapping writes, so this should be resolved before merge.
TheGreatAxios
left a comment
There was a problem hiding this comment.
Review · Blocking
The current owner-token fix handles ordinary replacement cleanup, but stale reclamation still has a compare/unlink race.
src/auth/oauth/store.ts:95— Two reclaimers can both validate the old inode/content. One unlinks and acquires a replacement, then the second performs its already-approved pathname unlink and removes that replacement. Both can subsequently enter the profile-store critical section. The test atsrc/auth/oauth/oauth.test.ts:335replaces the lock before validation, so it does not exercise this interleaving.
Could we use an atomic lock shape whose stale cleanup cannot remove a recreated owner—for example an owner file inside an exclusively-created lock directory, where cleanup unlinks the owner and rmdir cannot remove a replacement’s non-empty directory—and add a coordinated two-reclaimer regression?
|
Closing this implementation rather than continuing the lock-protocol patch cycle. CL-6713 remains a valid concurrency problem, but this branch's user-space stale-lock recovery has accumulated crash and reclamation races and is no longer a safe or reviewable direction. No additional dependency will be added. The issue is returning to backlog for a fresh design from the read-modify-write invariant. |
Summary
Verification
Fixes CL-6713