Skip to content

Fix flaky Ruby nonblocking server tests#3368

Open
kpumuk wants to merge 1 commit intoapache:masterfrom
kpumuk:nonblocking-close
Open

Fix flaky Ruby nonblocking server tests#3368
kpumuk wants to merge 1 commit intoapache:masterfrom
kpumuk:nonblocking-close

Conversation

@kpumuk
Copy link
Copy Markdown
Contributor

@kpumuk kpumuk commented Mar 27, 2026

Repeated Ruby suite runs exposed nondeterministic failures in the nonblocking server specs. The failures were caused by incomplete teardown of the Ruby nonblocking server path, which left resources alive across runs and made test ordering matter.

  • Use ephemeral ports in the specs instead of a fixed port, as the hardcoded port made repeated runs race rebinding and produced EADDRINUSE-style failures unrelated to the behavior under test.
  • Wait for the server to be listening before creating clients, because starting the server thread was not enough to guarantee the accept side was ready, so client setup could race server startup.
  • Change the spec teardown from raw Thread#kill to shutdown plus join, with kill only as a fallback - raw kill made teardown timing-dependent and left cleanup incomplete under repeated suite runs.
  • Same in IOManager#ensure_closed, kill and then join the I/O thread before forced cleanup. Thread#kill is asynchronous; joining makes forced cleanup synchronous so teardown does not race a still-unwinding I/O thread.
  • ^ This allows us to close tracked connections during forced cleanup in ensure_closed. Addresses the situation when the server is torn down abruptly, and sockets remain open and accumulate across runs.
  • Did you create an Apache Jira ticket? (Request account here, not required for trivial changes)
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit? (not required, but preferred)
  • Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
  • If your change does not involve any code, include [skip ci] anywhere in the commit message to free up build resources.

@mergeable mergeable bot added the ruby label Mar 27, 2026
@kpumuk kpumuk force-pushed the nonblocking-close branch from 6e82073 to cb31093 Compare March 27, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant