Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: correct current_try increment during step retries#257

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

Merged
jimsynz merged 2 commits intomainfromadd-current_try-increment_test
Aug 7, 2025

Conversation

@jimsynz
Copy link
Contributor

@jimsynzjimsynz commentedAug 7, 2025
edited
Loading

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept theAI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

Summary

Fix bug where `current_try` was not properly incremented during step retries, causing incorrect attempt numbering in retry scenarios.

Problem

The `current_try` context value was not being incremented correctly during step retries:

  • First attempt: `current_try = 0` ✓
  • First retry: `current_try = 0` ❌ (should be 1)
  • Second retry: `current_try = 1` ❌ (should be 2)

This was caused by a bug in the `increment_retries` function using an incorrect default value in `Map.update/4`.

Root Cause

The issue was in both `lib/reactor/executor/async.ex` and `lib/reactor/executor/sync.ex`:

```elixir

Incorrect - sets retry count to 0 for first retry

Map.update(state.retries, step.ref, 0, &(&1 + 1))

Correct - sets retry count to 1 for first retry

Map.update(state.retries, step.ref, 1, &(&1 + 1))
```

Additionally, the retry limit check used `>=` instead of `>`, which prevented the correct number of retries when `max_retries` was set.

Solution

  1. Fixed `increment_retries` function: Changed default value from `0` to `1` in `Map.update/4`
  2. Updated retry limit check: Changed from `>=` to `>` for correct `max_retries` semantics
  3. Added comprehensive test: Includes test case contributed by@skanderm that demonstrates the fix

Changes

  • `lib/reactor/executor/async.ex`: Fix increment_retries and retry limit check
  • `lib/reactor/executor/sync.ex`: Fix increment_retries and retry limit check
  • `test/reactor/executor/async_test.exs`: Update test expectation for new behavior
  • `test/reactor/executor/compensation_test.exs`: Add failing test case from@skanderm

Test Results

✅ All existing tests pass
✅ New test case passes with correct `current_try` progression
✅ No regressions in retry behavior
✅ `mix check` passes all quality checks

The fix ensures `current_try` correctly progresses: 0 → 1 → 2 instead of the previous incorrect 0 → 0 → 1 progression.

Includes the reproduction test from#243

@jimsynzjimsynz requested a review froma teamAugust 7, 2025 04:40
Comment on lines 68 to 73
# Current behavior (current_try does not immediately increment).
# Uncomment to make the test pass:
# {:run_start, _, 0},
# {:run_error, %RunStepError{error: :fail}, 0},
# {:compensate_start, %RunStepError{error: :fail}, 0},
# :compensate_retry,

Choose a reason for hiding this comment

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

Suggested change
# Current behavior (current_try does not immediately increment).
# Uncomment to make the test pass:
# {:run_start, _, 0},
# {:run_error, %RunStepError{error: :fail}, 0},
# {:compensate_start, %RunStepError{error: :fail}, 0},
# :compensate_retry,

Fix bug where current_try was not properly incremented during step retriesdue to incorrect default value in increment_retries function.The issue was in Map.update/4 usage:- Map.update(retries, step_ref, 0, &(&1 + 1)) set retry count to 0 for first retry- Should be Map.update(retries, step_ref, 1, &(&1 + 1)) to set retry count to 1Also updated retry limit check from >= to > for correct max_retries semantics:- max_retries 1 should allow 1 retry (2 total attempts)- Previous check retry_count >= max_retries prevented thisChanges:- lib/reactor/executor/async.ex: Fix increment_retries default and limit check- lib/reactor/executor/sync.ex: Fix increment_retries default and limit check- test/reactor/executor/async_test.exs: Update test expectation- test/reactor/executor/compensation_test.exs: Add test case from@skandermFixes current_try progression: 0 → 1 → 2 instead of 0 → 0 → 1
@jimsynzjimsynzforce-pushed theadd-current_try-increment_test branch from478c80d to32c4827CompareAugust 7, 2025 20:45
@jimsynzjimsynz merged commitd2a2ee1 intomainAug 7, 2025
22 checks passed
@jimsynzjimsynz deleted the add-current_try-increment_test branchAugust 8, 2025 03:26
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@barnabasJbarnabasJbarnabasJ approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@jimsynz@barnabasJ@skanderm

[8]ページ先頭

©2009-2025 Movatter.jp