fix(core): retry entire SQLite transaction on DatabaseBusy#34533
Open
FrozenPandaz wants to merge 1 commit intomasterfrom
Open
fix(core): retry entire SQLite transaction on DatabaseBusy#34533FrozenPandaz wants to merge 1 commit intomasterfrom
FrozenPandaz wants to merge 1 commit intomasterfrom
Conversation
Previously the retry_db_operation_when_busy macro only wrapped conn.transaction() (the BEGIN step). Operations inside the transaction and the COMMIT were not retried, causing crashes when the DB was busy during those steps. Now the entire begin-execute-commit sequence is wrapped in a single retry macro call using and_then.
Contributor
|
View your CI Pipeline Execution ↗ for commit b3a6ef2
☁️ Nx Cloud last updated this comment at |
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Current Behavior
When multiple Nx processes (task hasher, daemon, workers) access the SQLite database concurrently, the
NxDbConnection::transaction()method only retries the BEGIN step using theretry_db_operation_when_busy!macro. Operations executed inside the transaction and the COMMIT are not retried, so if the database is busy during those steps, the task crashes with:This is particularly common during parallel task hashing with continuous tasks, where
TaskDetails.recordTaskDetails()andRunningTasksServicecompete for write access.Expected Behavior
The entire transaction (begin, execute, commit) is retried as a single unit when any step encounters a
DatabaseBusyerror. If the database is busy during the operation or commit, the transaction is automatically rolled back (via drop) and retried with the same exponential backoff used everywhere else.Related Issue(s)