Skip to content

Comments

fix(core): retry entire SQLite transaction on DatabaseBusy#34533

Open
FrozenPandaz wants to merge 1 commit intomasterfrom
fix-db-lock
Open

fix(core): retry entire SQLite transaction on DatabaseBusy#34533
FrozenPandaz wants to merge 1 commit intomasterfrom
fix-db-lock

Conversation

@FrozenPandaz
Copy link
Collaborator

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 the retry_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:

Error: DB transaction operation error: SqliteFailure(Error { code: DatabaseBusy, extended_code: 5 }, Some("database is locked"))

This is particularly common during parallel task hashing with continuous tasks, where TaskDetails.recordTaskDetails() and RunningTasksService compete for write access.

Expected Behavior

The entire transaction (begin, execute, commit) is retried as a single unit when any step encounters a DatabaseBusy error. 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)

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.
@FrozenPandaz FrozenPandaz requested review from a team as code owners February 20, 2026 19:00
@nx-cloud
Copy link
Contributor

nx-cloud bot commented Feb 20, 2026

View your CI Pipeline Execution ↗ for commit b3a6ef2

Command Status Duration Result
nx affected --targets=lint,test,test-kt,build,e... ✅ Succeeded 15m 39s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3m 22s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 8s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗
nx-cloud record -- nx format:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-20 21:13:55 UTC

@netlify
Copy link

netlify bot commented Feb 20, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit b3a6ef2
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6998af5131e2b8000803eb09
😎 Deploy Preview https://deploy-preview-34533--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Feb 20, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit b3a6ef2
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/6998af514c317b0008298aac
😎 Deploy Preview https://deploy-preview-34533--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant