Repository navigation
fix(sqlite): report lock contention as retryable - #550
Open
chuiwenwei wants to merge 1 commit into
Open
chuiwenwei wants to merge 1 commit into
chuiwenwei wants to merge 1 commit into
Conversation
A SQLite write that waits out busy_timeout raises OperationalError and used to reach the catch-all handler as a 500. Classify only lock/busy errors as DatabaseBusyError and map it to 503 with Retry-After: 1; every other operational error still propagates unchanged. The session scope rolls the transaction back before raising, so nothing is committed. Add a real BEGIN IMMEDIATE lock test, an unrelated OperationalError test, and an HTTP integration test that proves 503 then 200 after the lock is released. Refs EverMind-AI#498.
This branch has not been deployed
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.
Summary
A SQLite write that waits out
busy_timeoutraisesOperationalErrorandused to reach the catch-all handler as a 500. Classify only lock/busy
errors as
DatabaseBusyErrorand map them to 503 withRetry-After: 1;every other operational error still propagates unchanged. The session
scope rolls the transaction back first, so nothing is committed.
Closes #498.
Area
Verification
Additional tests:
test_session_scope_maps_lock_contention_to_database_busyholds a realBEGIN IMMEDIATElock and assertsDatabaseBusyError.test_session_scope_leaves_other_operational_errors_unchangedproves amissing-table error is not misclassified.
test_locked_sqlite_returns_503_then_succeedsdrives the productionhandler: 503
DATABASE_BUSY+Retry-After, then 200 after release.Checklist
main..envfiles, dependency folders, or generated output.Notes for Reviewers
DATABASE_BUSYcode because the response has aconcrete retry hint; if you prefer reusing
EXTERNAL_SERVICE_UNAVAILABLE,it is a one-line change plus test updates.
DatabaseBusyErrorstays underStorageError; cascade retryclassification is out of scope for this PR.
sqlite_errorcode & 0xFFand falls back to thedatabase is lockedmessage for drivers that do not expose the code.By submitting this pull request, I agree that my contribution is licensed under
the Apache License 2.0.