-
Notifications
You must be signed in to change notification settings - Fork 419
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix sporadic failures testing with JRuby #1012
Fix sporadic failures testing with JRuby #1012
Conversation
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.
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.
This avoids getting stuck and waiting forever if something goes awry.
Existing commits up to this point fix the following:
I have at least one other intermittent failure I need to investigate:
|
This error just showed up once on the Ruby 3.2 CI jobs for this PR:
|
TR failure in https://github.com/ruby-concurrency/concurrent-ruby/actions/runs/6792582483 does not seem related to my changes. |
a6603e4
to
27f7833
Compare
Agreed. Those look very racy and asserting that a thread is sleeping seems troublesome. I'd suggest rewriting those something like this: it "cannot be acquired when another thread holds a write lock" do
latch = CountDownLatch.new
avoid_latch = CountDownLatch.new # expect this latch never to be reached
threads = [
in_thread { lock.acquire_write_lock; latch.count_down },
in_thread { latch.wait; lock.acquire_write_lock; avoid_latch.count_down }
]
expect { Timeout.timeout(1) { threads[0].join }}.not_to raise_error
expect(threads[0]).to hold(lock).for_write
expect(threads[1]).not_to hold(lock).for_write
wait_up_to(0.2) { threads[1].status == 'sleep' }
# more reliable expectations
expect(avoid_latch.wait(0.2)).to be false
expect(lock.try_write_lock).to be false
end But also could probably be in another PR---not that I am anyone to say one way or another. |
I'm not sure what would be causing the TR segfaults in https://github.com/ruby-concurrency/concurrent-ruby/actions/runs/6792582483 so I'l lleave that for TR folks to figure out. The other TR failure in https://github.com/ruby-concurrency/concurrent-ruby/actions/runs/6792654287/job/18466286918?pr=1012 might be another flaky test, as @bensheldon suggested above, but I'm not sure of the right fix and I have not seen it on JRuby yet. If it's ok, I'd like to merge what we have here so JRuby can start to have some consistency in concurrent-ruby testing. If we see more sporadic failures, I'll open another issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
A collection of fixes to make specs more robust or fix issues causing sporadic failures on JRuby.