Skip to content

[SYSTEMDS-3960] Fix federated worker readiness probe on delayed connections - #2587

Open
gaturchenko wants to merge 3 commits into
apache:mainfrom
gaturchenko:worker-coord-network-delay
Open

[SYSTEMDS-3960] Fix federated worker readiness probe on delayed connections#2587
gaturchenko wants to merge 3 commits into
apache:mainfrom
gaturchenko:worker-coord-network-delay

Conversation

@gaturchenko

Copy link
Copy Markdown
Contributor

With any delay on the worker's interface, currently every federated test fails before it starts, while the worker is listening the whole time. FederatedWorkerUtils.tryConnect allocated 25ms per connect attempt, but a TCP handshake needs two traversals of the link which are ~100ms under the delay above. Every attempt expired with a SocketTimeoutException, which is an IOException and therefore indistinguishable from a closed port, so the probe never succeeded.

The following changes were implemented:

  • Per-attempt connect budget increased from 25ms to 2s. A closed port is refused by the kernel immediately, so it only applies once a handshake is in progress. Additionally, 2s covers one lost SYN, retransmitted after ~1s
  • Each attempt is capped by the time left until the overall deadline (attemptTimeout), so a slow connect cannot exceed it. The returned value of 0 implies the attempt was never made
  • The waitForWorkers now rechecks the deadline per port, which can now cost up to 2s each
  • Six new tests are added verifying the change

@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.38%. Comparing base (9dccbc3) to head (c58a3b1).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2587      +/-   ##
============================================
- Coverage     71.44%   71.38%   -0.07%     
- Complexity    50437    50532      +95     
============================================
  Files          1629     1632       +3     
  Lines        195513   196229     +716     
  Branches      38118    38199      +81     
============================================
+ Hits         139686   140069     +383     
- Misses        44867    45122     +255     
- Partials      10960    11038      +78     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gaturchenko

Copy link
Copy Markdown
Contributor Author

Waiting for the review by @ywcb00

@ywcb00 ywcb00 self-assigned this Aug 19, 2026

@ywcb00 ywcb00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for this PR @gaturchenko. :)
I left some comments in the code. Also, could you please try to shorten the method headers and in-line documentation if possible?
Thanks and all the best, David

Comment on lines +28 to +29
* Test helpers that block until a federated worker is accepting TCP connections on its port. The federated worker opens
* its TCP port after Netty's {@code bind().sync()} returns; a successful TCP connect to that port therefore indicates

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While removing the html paragraph tag is good, please preserve the line break.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, please see a4b2adc

* @return the timeout to pass to {@link Socket#connect}, or 0 if no attempt should be made. Never returns 0 while
* time is left, because {@code connect} reads a timeout of 0 as 'infinite'.
*/
public static int attemptTimeout(long remainingMs) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name here is ambiguous. While this method returns the timeout for a connection attempt, the name could also mean that it attempts the connection with a timeout.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, please see a4b2adc

private static boolean tryConnect(int port) {
private static boolean tryConnect(int port, long deadline) {
final int timeout = attemptTimeout(deadline - System.currentTimeMillis());
if(timeout == 0) // out of time, do not start another attempt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition here can be rewritten to a "less than or equal" condition, thereby removing the necessity of the separate condition in attemptTimeout() and allowing for replacing the call to attemptTimeout() by the single remaining code line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, please see a4b2adc

private static final int TOLERATED_HANDSHAKE_MS = 1000;

@Test
public void attemptBudgetCoversADelayedHandshake() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate verifying the code through these unit tests.
However, I think these tests are too fine-grained for testing the test framework. Please remove the tests that evaluate attemptTimeout() directly (aligning with removing of this method, as commented below), and move the remaining tests to the FederatedUrlParserTest.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, please see c58a3b1

@github-project-automation github-project-automation Bot moved this from In Progress to In Review in SystemDS PR Queue Aug 21, 2026
@gaturchenko
gaturchenko requested a review from ywcb00 August 21, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants