Skip to content

Add automatic retry for serializable transaction failures#140

Merged
fractaledmind merged 2 commits intomainfrom
retry-workflow-initialization
Jan 25, 2026
Merged

Add automatic retry for serializable transaction failures#140
fractaledmind merged 2 commits intomainfrom
retry-workflow-initialization

Conversation

@fractaledmind
Copy link
Owner

@fractaledmind fractaledmind commented Jan 25, 2026

  • Add AcidicJob. initialize_workflow_max_retries config (default: 3)
  • Add InitializeWorkflowRetriesExhaustedError
  • 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

- 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
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@fractaledmind fractaledmind merged commit 089ea71 into main Jan 25, 2026
44 checks passed
@fractaledmind fractaledmind deleted the retry-workflow-initialization branch January 25, 2026 23:39
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.

Automatically retry the serializable transaction for find/create the Run record

2 participants