From f746228a8f9d1912c50185ed0389cdcba58d3022 Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Tue, 7 Nov 2023 16:17:05 -0600 Subject: [PATCH 1/4] Wait for blockers to proceed If this spec proceeds to reset the barrier before there are any waiters, the reset will not trigger them and the spec will fail. This at least tries to ensure that the waiter is there and will be interrupted as expected. --- spec/concurrent/atomic/cyclic_barrier_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/concurrent/atomic/cyclic_barrier_spec.rb b/spec/concurrent/atomic/cyclic_barrier_spec.rb index 3a2bb2426..3e882d105 100644 --- a/spec/concurrent/atomic/cyclic_barrier_spec.rb +++ b/spec/concurrent/atomic/cyclic_barrier_spec.rb @@ -71,6 +71,7 @@ module Concurrent end start_latch.wait(1) + Thread.pass until barrier.number_waiting == 1 barrier.reset expect(barrier).not_to be_broken From ada6288a347fb2b4558cd44e8ccc0114bf5887c5 Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Tue, 7 Nov 2023 16:17:57 -0600 Subject: [PATCH 2/4] Bump join timeout up for slower system On slower or heavily-loaded systems, such as CI, this join may need more than one second. Give it ten before giving up and raising an error. --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2a8fbc54a..d191183f6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -53,7 +53,7 @@ def requires=(paths) config.after :each do while defined?(@created_threads) && @created_threads && (thread = (@created_threads.pop(true) rescue nil)) thread.kill - thread_join = thread.join(1.0) + thread_join = thread.join(10.0) expect(thread_join).not_to be_nil, thread.inspect end end From a8fa48632c07e7cc163046f4669de649a3e8d05a Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Tue, 7 Nov 2023 19:23:29 -0600 Subject: [PATCH 3/4] Use repeat_until_success to wait for waiters This avoids getting stuck and waiting forever if something goes awry. --- spec/concurrent/atomic/cyclic_barrier_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/concurrent/atomic/cyclic_barrier_spec.rb b/spec/concurrent/atomic/cyclic_barrier_spec.rb index 3e882d105..8ed899d67 100644 --- a/spec/concurrent/atomic/cyclic_barrier_spec.rb +++ b/spec/concurrent/atomic/cyclic_barrier_spec.rb @@ -71,7 +71,7 @@ module Concurrent end start_latch.wait(1) - Thread.pass until barrier.number_waiting == 1 + repeat_until_success { expect(barrier.number_waiting).to eq 1 } barrier.reset expect(barrier).not_to be_broken From 27f7833829a93283884722b05c85abee9da1e360 Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Tue, 7 Nov 2023 19:35:19 -0600 Subject: [PATCH 4/4] Also skip on JRuby until we can fix sporadic failures --- spec/concurrent/edge/erlang_actor_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/concurrent/edge/erlang_actor_spec.rb b/spec/concurrent/edge/erlang_actor_spec.rb index ed94607dc..5ab7c4e48 100644 --- a/spec/concurrent/edge/erlang_actor_spec.rb +++ b/spec/concurrent/edge/erlang_actor_spec.rb @@ -918,7 +918,7 @@ end specify "timing out" do - skip('flaky on truffleruby') if Concurrent.on_truffleruby? + skip('flaky on truffleruby and jruby') if Concurrent.on_truffleruby? || Concurrent.on_jruby? count_down = Concurrent::CountDownLatch.new body = { on_thread: -> { m = receive; count_down.wait; reply m },