- Notifications
You must be signed in to change notification settings - Fork1k
feat: improve transaction safety in CompleteJob function#17970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This commit refactors the CompleteJob function in provisionerdserver.go touse database transactions more consistently for better atomicity guarantees.The large function was broken down into three specialized handlers:- completeTemplateImportJob- completeWorkspaceBuildJob- completeTemplateDryRunJobEach handler now uses the Database.InTx wrapper to ensure all databaseoperations for a job completion are performed within a single transaction,preventing partial updates in case of failures.Added comprehensive tests for transaction behavior for each job type.Fixes#17694🤖 Generated with [Claude Code](https://claude.ai/code)Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Since this is just a refactor, I found these diffs easier to grok.
The only diff is in workspace build, the insertion of timings was moved
Template import:https://www.diffchecker.com/ugtjYQgz/
Workspace build:https://www.diffchecker.com/KuvTwAPu/
DryRun:https://www.diffchecker.com/MxShZo2U/
b7462fb
intomainUh oh!
There was an error while loading.Please reload this page.
This PR refactors the CompleteJob function to use database transactions more consistently for better atomicity guarantees. The large function was broken down into three specialized handlers:
Each handler now uses the Database.InTx wrapper to ensure all database operations for a job completion are performed within a single transaction, preventing partial updates in case of failures.
Added comprehensive tests for transaction behavior for each job type.
Fixes#17694
🤖 Generated withClaude Code