fix(auth): auth profile lock timeout/creation failure blocks all RPC calls (regression)
Bug Report
Description
Auth profile file-lock acquisition fails for hundreds of users, blocking every RPC call that touches the auth profile store. This is a regression of the fix shipped in #1612 — the stale-lock recovery logic isn't covering all failure modes.
Sentry issues:
- OPENHUMAN-TAURI-H1 — Timed out waiting for auth profile lock (990 events)
- OPENHUMAN-TAURI-H8 — Failed to create auth profile lock (822 events)
Combined impact: 1,812 events. Every RPC method that calls acquire_lock() fails — app_state_snapshot, auth reads, profile writes — leaving the app non-functional until the lock clears or the user restarts.
Error
Timed out waiting for auth profile lock
Failed to create auth profile lock
- Platform: Windows x86_64 (10.0.26200)
- Version: [email protected]
- Environment: production
Root Cause Analysis
src/openhuman/credentials/profiles.rs:526-599 — acquire_lock() uses create_new(true) with a 10s busy-wait + stale-PID recovery (#1612 fix). Two failure modes remain:
-
H1 (timeout):
clear_lock_if_stale()runs once (cleared_staleflag), but if the owning process is still alive (e.g. hung RPC handler holding the lock longer than 10s), every subsequent caller times out. No deadlock detection or lock-stealing after extended hold. -
H8 (creation failure):
retry_with_backoffretries 6 times but the error is notAlreadyExists— it's a filesystem-level failure (permissions, AV interference on Windows). The error falls through to the non-AlreadyExistsbranch and returns immediately with no recovery.
The 990 H1 events suggest a single long-held lock cascades into a retry storm across all concurrent RPC calls — each one independently waiting 10s, then all failing together.
Cascade
| Call site | Behavior | File:Line |
|---|---|---|
app_state_snapshot |
Returns error to UI → boot gate blocked | profiles.rs:591 |
| All auth-dependent RPCs | Timeout after 10s → UI shows error loop | profiles.rs:591 |
| Profile writes | Fail immediately on fs error | profiles.rs:596 |
Proposed Fix
- Increase stale-lock recovery: re-check PID liveness periodically during the busy-wait (not just once) in case the owning process crashes mid-hold
- Add lock-hold timeout: if the lock file is older than e.g. 30s, force-remove regardless of PID liveness (defensive against hung holders)
- Windows-specific: handle AV/permission lock interference on
create_new— retry with backoff on permission errors, not justAlreadyExists - Add tests for concurrent lock contention and long-hold scenarios
Labels
sentry-traced-bug, os:windows, bug, priority: critical, area: core
Edit: First time user here. Can't even get in!