Repository navigation
[Bulk transition] PR-1881: Conflict handling & automatic per-subset retry - #575
Open
stevetrinh wants to merge 1 commit into
Open
stevetrinh wants to merge 1 commit into
stevetrinh wants to merge 1 commit into
Conversation
stevetrinh
added this pull request to stack #569
October 5, 2026 09:20
Thread on_failure: and a new conflict_retry_attempts: option through BulkTransition.call -> #persist -> the adapter's bulk_create -> BulkCreate.call. On exhausting BulkCreate's internal RecordNotUnique retry, on_failure: :collect (default) now surfaces the remaining survivors as :conflict failures instead of raising the raw AR error; on_failure: :raise raises Statesman::BulkTransitionConflictError, wrapping the original RecordNotUnique as #cause. The retry bound itself is now caller-configurable instead of a hardcoded constant. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.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.
This pull request adds configurable retry and failure handling options to bulk state transitions in Statesman, making ActiveRecord adapter behavior more robust and flexible in the face of persistent insert conflicts. The main changes introduce new
on_failureandconflict_retry_attemptsoptions, allow callers to control how many times a bulk insert is retried after a conflict, and determine whether to raise or collect failures after retries are exhausted. These options are threaded through all relevant code paths and validated for correctness. Comprehensive tests are added to ensure the new behaviors work as intended.Bulk transition retry and failure handling improvements:
on_failure:andconflict_retry_attempts:options toBulkTransition.callandbulk_createmethods, allowing callers to specify how many times to retry bulk inserts after a conflict and whether to raise or collect failures when retries are exhausted. [1] [2] [3] [4] [5]BulkCreatelogic to respect the new options: after exhausting retries, it either raises a newBulkTransitionConflictError(wrapping the originalRecordNotUnique) or collects all conflicted items as failures, depending onon_failure.API and interface consistency:
Adapters::Memory) accepts the new options for interface parity, even though they have no effect in that context.Validation and error handling:
conflict_retry_attemptsis a positive integer, raising anArgumentErrorotherwise.Testing improvements:
:collectand:raisefailure modes. [1] [2] [3]