Skip to content

Add randomized exponential backoff to file lock retries#60

Merged
jancurn merged 1 commit into
mainfrom
claude/analyze-lockfile-retry-Rqr0T
Mar 12, 2026
Merged

Add randomized exponential backoff to file lock retries#60
jancurn merged 1 commit into
mainfrom
claude/analyze-lockfile-retry-Rqr0T

Conversation

@jancurn

@jancurn jancurn commented Mar 12, 2026

Copy link
Copy Markdown
Member

Summary

Improved file lock retry mechanism by enabling randomized exponential backoff to reduce contention when multiple processes compete for the same lock.

Changes

  • Enabled the randomize option in the retry configuration for withFileLock() function
  • This causes retry delays to be randomized within the exponential backoff range, preventing thundering herd scenarios where multiple processes retry simultaneously

Implementation Details

The change modifies the retry strategy in src/lib/file-lock.ts by setting randomize: true in the retry options. Combined with the existing minTimeout: 100 and maxTimeout: LOCK_TIMEOUT settings, this ensures that when multiple processes are waiting for a lock, their retry attempts are staggered randomly rather than synchronized, significantly reducing lock contention and improving overall system performance.

https://claude.ai/code/session_01BBeekEng72MXvQWWnPZohs

Reduces contention when multiple processes compete for the same lock
by adding jitter (randomize: true) to the proper-lockfile retry options.

https://claude.ai/code/session_01BBeekEng72MXvQWWnPZohs
@jancurn jancurn merged commit 41e1b25 into main Mar 12, 2026
6 checks passed
@jancurn jancurn deleted the claude/analyze-lockfile-retry-Rqr0T branch March 12, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants