Skip to content

Conversation

@CJStadler
Copy link

When strategies are given in an arraythrottled? is called in order for each strategy in the array. When it is called for one concurrency strategy and evaluates to false it always adds the job to the in progress set. But if it evaluates to true for a later strategy then the job will not actually be executed.

This PR fixes this bug by calling finalize! on each strategy that throttled? was already called on, removing the job from their in progress sets. This is a similar to how Strategy#throttled? already calls finalize! on its concurrency strategies that were already evaluated if the threshold strategy throttles the job.

It seems inefficient to add each job to sets only to immediately remove it. A possibly more efficient approach is shown in CJStadler@12c4f35689020. That would require more extensive changes though.

Fixes #220

This spec fails if the dynamic rule is specified after the static
rule.

In this case when `throttle?` is called for the 4th job with the arg `99`
the static rule returns `false` and adds the job to the in progress set,
but the dynamic rule then returns `true`, so the job should not be
executed.

If the order the rules are configured is reversed then dynamic rule
will execute first, return `true`, and the static rule will never run
so the job will not be added to the in progress set.
When a later strategy throttles the job. This removes the job from
the in progress set, since it is not actually running.
@codecov
Copy link

codecov bot commented Oct 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.98%. Comparing base (854dffe) to head (10ebdd2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #222      +/-   ##
==========================================
+ Coverage   98.97%   98.98%   +0.01%     
==========================================
  Files          19       19              
  Lines         486      493       +7     
  Branches       85       87       +2     
==========================================
+ Hits          481      488       +7     
  Misses          5        5              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Jobs may be throttled incorrectly depending on the order of concurrency strategies

1 participant