Repository navigation
Lock the description store while a run writes to it [patch] - #202
Merged
Merged
Conversation
Every run loaded the whole store at start and saved its whole in-memory copy back, so two Scans over different folders, or an Import or Configure during a Scan, overwrote each other's additions without a word. Scan, Import and Configure now hold an exclusive lock file beside the store for the whole run and reload the store under it. A second writing run fails fast with a clear message instead of losing work. Search, Stats and Export only read, so they don't take the lock. Fixes #164 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TTeaDNAaTEviJbNWuEi5hP
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TTeaDNAaTEviJbNWuEi5hP
|
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.



Fixes #164
What was wrong
Each process loads the whole store when it starts, and every save writes that whole in-memory copy back. When two runs overlapped, whichever saved last won:
The
lockinScanonly serialized threads inside one process.Change
This is option 1 from the issue, which the triage recommended.
StoreLock. A new class that takes an exclusive lock file (FileShare.None) beside the store, atAppData.Path/ImageDescriber.lock.TryAcquirereturnsnullwhile another run holds it.BaseVerb.WritesStoreis overridden totrueonScan,ImportandConfigure. For those verbs,BaseVerb<T>.Run()does three things:Search,StatsandExportonly read the store, so they don't take the lock.Tests
StoreLockTestscovers three things:WritesStore.Importstarted while another run holds the lock prints the busy message and never runs. The test can tell because its input file is missing, so a run would have printed "File not found".With the lock wiring removed from
BaseVerb, the two verb tests fail. The full suite passes: 90 passed, 1 skipped.Note on #200
#200 ("Exit non-zero when … a verb fails") touches
BaseVerb.Runtoo. The two branches merge cleanly; I checked withgit merge-tree. Whichever lands second may want the busy refusal to setFailed = true, so a script sees the refused run as a failure.🤖 Generated with Claude Code
https://claude.ai/code/session_01TTeaDNAaTEviJbNWuEi5hP
Generated by Claude Code