chore(release): memory-core 0.3.2 - lock-tolerant LocalBackend commit#20
Merged
Conversation
The per-write git commit (writeDoc/edit/delete) now retries on transient .git/index.lock contention from a concurrent sync-cycle commit, instead of surfacing a spurious 'Command failed: git commit' to the caller. - git.ts: isIndexLockError classifier + withIndexLockRetry (5 retries, 50ms steps capped 250ms); only the lock race is retried, every other git error throws immediately so real failures are never masked. - local-backend.ts: wrap the add/status/commit mutations in the retry. - No-op-write short-circuit and all existing behavior unchanged. Closes #19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #19
Problem
LocalBackend's per-write git commit (
writeDoc/edit/delete->git add+git commit) was notindex.lock-retry-tolerant. When a couch/git sync-cycle commit held.git/index.lockat the same moment, the engine write failed with a spuriousCommand failed: git commit. CLI M5 adversarial verification (20s write+sync storm: 211 CRUD + 138 sync ticks) saw ~9/211 writes and 10/138 syncs hit this. Data always converged (atomic rename + next tick) - only the caller saw a phantom failure.Fix
A short, bounded retry on
index.lockcontention, mirroring the classify logic the sync cycles already use.git.ts:isIndexLockError()classifier (matchesindex.lock/ "another git process seems to be running", readserr.message+ anyerr.stderr) +withIndexLockRetry()- 5 retries, 50ms steps capped at 250ms (~750ms worst case), then surfaces the original error.local-backend.ts: wrap the mutatingadd/status/commitcalls in the retry.Tests (
test/m5-commit-lock-retry.test.ts, 11 new)isIndexLockErrorclassification: real lock stderr, "another git process" wording, separatestderrprop, false for non-lock + non-Errors.withIndexLockRetry: retries a lock error then succeeds; fails fast on a non-lock error (no retry, no wait); bounded - a permanent lock surfaces after exactly 5 retries with backoffs[50,100,150,200,250]..git/index.lockis released mid-retry; a permanent lock surfaces the error in < 3s (no hang); no-op short-circuit unaffected; 20 concurrent writes all land while an external process cycles the index lock (racing-writers proof).Reverting only the wiring (keeping the helpers) reproduces the bug: both integration tests fail with
Command failed: git add -A.Full
npm run verifygreen: 21 files, 165 tests. Zero new deps.