Add automatic retry for serializable transaction failures#140
Merged
fractaledmind merged 2 commits intomainfrom Jan 25, 2026
Merged
Add automatic retry for serializable transaction failures#140fractaledmind merged 2 commits intomainfrom
fractaledmind merged 2 commits intomainfrom
Conversation
- Add AcidicJob.serializable_transaction_max_retries config (default: 3) - Add SerializableTransactionRetriesExhaustedError - Extract find_or_create_execution method with built-in retry logic - Catch ActiveRecord::SerializationFailure and ActiveRecord::Deadlocked - Implement exponential backoff (50ms, 100ms, 200ms, etc.) Resolves #91
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements automatic retry logic for serializable transaction failures when initializing AcidicJob workflows. The feature addresses a known issue where serializable transactions can fail transiently due to concurrent access, requiring automatic retry handling.
Changes:
- Added configurable max retries with exponential backoff for serializable transaction failures
- Extracted workflow initialization logic into a new private method with built-in retry handling
- Added comprehensive test coverage for retry scenarios including success after retries, exhausted retries, and deadlock handling
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| lib/acidic_job.rb | Adds new configuration option initialize_workflow_max_retries with default value of 3 |
| lib/acidic_job/errors.rb | Introduces InitializeWorkflowRetriesExhaustedError exception for when retry attempts are exhausted |
| lib/acidic_job/workflow.rb | Refactors transaction logic into find_or_create_execution method with retry handling for SerializationFailure and Deadlocked exceptions using exponential backoff (50ms, 100ms, 200ms, etc.) |
| test/acidic_job/workflow_errors_test.rb | Adds four comprehensive tests covering serialization failure retry success, retry exhaustion, deadlock retry success, and configurable retry limits |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Resolves #91