GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Stop the open-uri test server racing its own socket close by aminmansuri · Pull Request #9718 · jruby/jruby Conversation
|
|
This is the one discovered during #9716 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This one also needs a deeper look.
This file is part of the MRI test suite copied from CRuby, so usually we don't like to make changes here. Obviously I did that already by removing the @thread.kill.
There's clearly something wrong with the sequence of events here when running on JRuby, so there's two possibilities I see:
You and I have attempted to fix the test, but I have always wanted more confidence that it's not a JRuby bug we're patching around.
The test fix might be the right way to go, but in that case we should also try to get this into open-uri.
I'd propose the following:
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
A litte background here: This simple server logic is now sprinkled over various parts of the CRuby test suite after the WEBrick library got moved out of the default stdlib. Formerly, WEBrick was used to manage these test servers, and it has much more robust logic for starting up and shutting down servers. I've never been quite satisfied with the new tests. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
There is an example of the teardown you would want in test/mri/net/http/utils.rb — @thread.kill followed by @thread.join — and it still fails intermittently on JRuby. Two tests errored that way on #9718's own CI run, TestNetHTTPKeepAlive#test_keep_alive_get_auto_retry and TestNetHTTP_v1_2#test_get__implicit_start, both Errno::EBADF raised from IO#close at line 35, the socket&.close in the ensure inside the accept loop. The thread is killed, unwinds into that ensure, the close raises, and join re-raises it into the test. Java 21 and Java 26 failed; Java 25 passed on the same commit. That may be the better case to reason from, since the kill and join are already there, so nothing can be blamed on their absence. The teardown — @thread&.kill then @thread&.join: jruby/test/mri/net/http/utils.rb Lines 47 to 50 in 6718ce1
The accept loop, with the socket&.close that raises at L35: jruby/test/mri/net/http/utils.rb Lines 28 to 39 in 6718ce1
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Reported JRuby issue as #9722. This one is separate: the open-uri teardown closes the server socket under a blocked accept with no kill, which raises on CRuby too — the helper's assumption, not an engine difference. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@aminmansuri Clarify for me what's left to do here... with the EBADF fix from #9723 do we still need this change? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Yes, still needed. They fix different things. #9723 fixed close after a thread is killed. This PR is about a server that is never killed: shutdown closes the socket while the thread is still waiting in accept. That raises IOError, on CRuby too, and the thread's rescue doesn't catch it, so the test fails. The fix does what CRuby does here: kill the thread first, then close. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
looking at the code should I put a To prevent a weird hang? If no timeout it could, under some very rare circumstances block forever. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ok, then we're back to my original problem with this change: why do we need to do it this way and CRuby just does def shutdown @thread.kill @server.close end These tests are synced from CRuby (which syncs with ruby/openuri, see https://github.com/ruby/open-uri/blob/master/test/open-uri/utils.rb#L29-L32) so any changes we make in our copy can easily get wiped out by future updates. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@aminmansuri If you're still out there I'm still interested in resolving this. The ideal situation is to be able to use CRuby's test without modifications, but only if the setup+teardown it includes is expected to work properly on JRuby. If there's a problem with the test, we need to upstream that along with our local changes, so those changes don't get wiped out. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'm traveling right now so I can't get to it for a while. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
At least 1 approving review is required to merge this pull request.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.