Skip to content

Commit 0370167

Browse files
authored
Merge pull request #100 from figma/dpashkevich/empty-worker-history-fallback
ruby: Rejoin queue when retry has no history
2 parents 0f7a10a + a2467b4 commit 0370167

4 files changed

Lines changed: 8 additions & 11 deletions

File tree

‎ruby/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ minitest-queue --queue redis://example.com \
4646
run -Itest test/**/*_test.rb
4747
```
4848

49-
Worker-history retries require the retry to retain its worker ID and queue build ID. Missing reservation history or suite chunk metadata fails the retry. The replay uses a local retry queue and does not rejoin the shared queue, so surviving workers must drain any remaining work. When centralized reporting is used, restarting every worker before the shared queue is exhausted fails the build rather than accepting an incomplete run.
49+
Worker-history retries require the retry to retain its worker ID and queue build ID. A worker retried before reserving tests rejoins the shared queue, while missing suite chunk metadata fails the retry. Replaying existing history uses a local retry queue and does not rejoin the shared queue, so surviving workers must drain any remaining work. When centralized reporting is used, restarting every worker before the shared queue is exhausted fails the build rather than accepting an incomplete run.
5050

5151

5252
If you'd like to centralize the error reporting you can do so with:

‎ruby/lib/ci/queue/redis/worker.rb‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,6 @@ def failed_test_ids(reservations)
541541
end
542542

543543
def worker_history_test_ids(reservations)
544-
raise WorkerHistoryError, "Reservation history is missing for worker #{worker_id}" if reservations.empty?
545-
546544
reservations.reverse.flat_map { |id| expand_reservation(id) }.uniq
547545
end
548546

‎ruby/test/ci/queue/redis_test.rb‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,10 @@ def test_retry_queue_with_worker_history
7171
assert_equal original_order, poll(retry_queue)
7272
end
7373

74-
def test_worker_history_retry_requires_reservations
75-
error = assert_raises(CI::Queue::Redis::WorkerHistoryError) do
76-
@queue.retry_queue(selection: :worker_history)
77-
end
74+
def test_worker_history_retry_without_reservations_is_empty
75+
retry_queue = @queue.retry_queue(selection: :worker_history)
7876

79-
assert_equal 'Reservation history is missing for worker 1', error.message
77+
assert_predicate retry_queue, :exhausted?
8078
end
8179

8280
def test_worker_history_retry_requires_complete_replay

‎ruby/test/integration/minitest_redis_test.rb‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,14 @@ def test_worker_history_retry_replays_all_reserved_tests
232232
assert_equal 'Ran 100 tests, 100 assertions, 0 failures, 0 errors, 0 skips, 0 requeues in X.XXs', output
233233
end
234234

235-
def test_worker_history_retry_fails_without_worker_reservations
235+
def test_worker_history_retry_rejoins_queue_without_worker_reservations
236236
run_worker_history_worker(retry_count: 0, build_id: 'missing-history', worker_id: '1')
237237

238238
out, = run_worker_history_worker(retry_count: 1, build_id: 'missing-history', worker_id: '2')
239239

240-
refute_predicate $?, :success?
241-
assert_includes out, 'Reservation history is missing for worker 2'
240+
assert_predicate $?, :success?
241+
assert_includes out, "The retry queue does not contain any failure, we'll process the main queue instead."
242+
assert_includes out, 'All tests were ran already'
242243
end
243244

244245
def test_worker_history_retry_fails_when_replay_stops_early

0 commit comments

Comments
 (0)