Repository navigation
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
|
CI Results
All checks passed. 🎉 |
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.



Part of #178 (the lock retry; the deep-crawl checkpoint will be a separate PR).
WAL mode and a 30s busy timeout already absorb most lock contention between site jobs, but a lock can still surface as
sqlite3.OperationalError: database is locked, for example at commit time. When that happened, the write simply failed.Every manifest write now goes through one helper that commits the write and, on a lock error, rolls back and retries after 0.5s, 1s and 2s before giving up. The retry reruns the whole unit of work, not just the statement that failed. That matters for
rekey, which deletes the old row and inserts the new one: a retry can't leave it with the old row gone and the new one missing. Any otherOperationalError, such as a disk error, is raised straight away.Lock errors are recognised by SQLite's result code (busy or locked), with a fallback to the message text for Python builds that don't expose the code. Schema setup at startup goes through the same helper, since several site jobs open the file at once.
The wait is a blocking
time.sleep, like the existing busy timeout, because the store is synchronous. It adds at most 3.5s on top of the busy timeout, and only when a lock outlasts it.Tests use a wrapped connection that reports "locked" a set number of times. They cover a write that succeeds on retry, a lock that outlasts every retry, a non-lock error that isn't retried, and a failed rekey that keeps the original row. All crawler tests pass at 96% coverage; ruff and mypy are clean.