runs/harness: a restarted test node binds a port it let go of, and another test can take it: forge run 1574 red on a timeout #100

Open
opened 2026-11-18 07:33:09 +00:00 by xemmerling · 0 comments
Owner

The forge workflow's run 1574 on main b70e9313 is red on one test of 3,547, and not by that commit: drivers::cargo::tests::a_run_driven_again_asks_its_build_of_the_whole_family_it_asked timed out at 180 s. Its stderr has one line: worker n1 ended: listen on port 36949: Address already in use (os error 98). t's own run of the same commit on t-testing passed (r33699b683a, 9 of 9).

Cause

A harness node's store is served on a port it keeps across a restart, "as a worker's --peer is: the other nodes' plans name it by it" (runs::harness::TestNode::peer_port, work). The first launch binds port 0 and remembers what the kernel gave (store::blobs::bind(port.load()), then port.store(bound)). TestNode::stop ends the worker's runtime, which closes the listener; restart binds the remembered number again. Between the two the port is nobody's, and it lies in the kernel's ephemeral range (36949 here), where every other test of the run binds port 0 and makes its outgoing connections. This test stops its node, starts a run, waits for a verdict and reopens the server before it restarts the node: seconds, with some 3,500 tests beside it. One of them was handed the port.

The second half is why it reads as a timeout and not as what it is: the worker's task ends with the error, the harness prints it (eprintln!("worker {who} ended: {e:#}")) and the test goes on waiting for a run no node will ever take.

Three tests restart a harness node: this one, drivers::cargo::tests_multi_tilo (issue 72's wave test) and one in runs::engine::tests. Whether issue 72's failures on the forge runner are partly this I have not read; its logs would say Address already in use.

Fix proposed

The invariant as written, kept without a gap: the TestNode binds its store's listener once and holds it for its whole life; each launch serves on a duplicate of it (try_clone of the standard listener, made a tokio one), so a stopped worker lets go of its duplicate only and the port stays the node's. No port number is ever bound a second time. And a worker task that ends with an error fails the test that is waiting on its node, with that error, instead of leaving it to its timeout.

It touches src/runs/harness.rs alone, no production code. I commission it now as a fix of the documented invariant; say if you would rather have it differently.

Landed 08:15:25Z 11-18: main f68f8f26

The node's half is done (the developer's 0012788d picked on d748ed8d; t's whole check set on t-testing green, run r7fea383c25, 8 passed and 5 answered from earlier runs in 324 s). A TestNode binds its store's socket once, when it is made, and holds it until it is dropped; each launch serves on a duplicate (try_clone, made a tokio listener in the node's runtime). The new test runs::engine::tests::a_stopped_nodes_store_port_is_still_its_own_and_its_restart_serves_on_it stops a node, finds its port refused to another bind while it is down, restarts it on the same port and passes a check on it. That it fails on the old code is reasoned, not run: there the stop closed the listener, so the bind succeeded.

One thing it changes for a test: the held socket stays listening while a node is down, so a connect to a stopped node waits in the backlog instead of being refused. No test stops a node another node fetches from; the wave test restarts one, which is down for its runtime's shutdown only.

Still open here: a worker task that ends with an error is only printed and the test waits to its timeout. The developer's survey of which tests see a worker end with an error on purpose was cut short (its local test run damaged the laptop's shared clone, issue 101), so that half is not built.

09:01Z 11-18: the forge workflow's first run to complete on a main that holds the fix is green: run 1579 on 86a540fc (test, fmt, clippy; runs 1575 to 1578 were cancelled by later pushes). One run says nothing of a failure that came about one run in fifteen; it shows the new test and the three restarting tests pass on the forge's runner.

The forge workflow's run 1574 on main b70e9313 is red on one test of 3,547, and not by that commit: `drivers::cargo::tests::a_run_driven_again_asks_its_build_of_the_whole_family_it_asked` timed out at 180 s. Its stderr has one line: `worker n1 ended: listen on port 36949: Address already in use (os error 98)`. t's own run of the same commit on t-testing passed (r33699b683a, 9 of 9). ## Cause A harness node's store is served on a port it keeps across a restart, "as a worker's `--peer` is: the other nodes' plans name it by it" (`runs::harness::TestNode::peer_port`, `work`). The first launch binds port 0 and remembers what the kernel gave (`store::blobs::bind(port.load())`, then `port.store(bound)`). `TestNode::stop` ends the worker's runtime, which closes the listener; `restart` binds the remembered number again. Between the two the port is nobody's, and it lies in the kernel's ephemeral range (36949 here), where every other test of the run binds port 0 and makes its outgoing connections. This test stops its node, starts a run, waits for a verdict and reopens the server before it restarts the node: seconds, with some 3,500 tests beside it. One of them was handed the port. The second half is why it reads as a timeout and not as what it is: the worker's task ends with the error, the harness prints it (`eprintln!("worker {who} ended: {e:#}")`) and the test goes on waiting for a run no node will ever take. Three tests restart a harness node: this one, `drivers::cargo::tests_multi_tilo` (issue 72's wave test) and one in `runs::engine::tests`. Whether issue 72's failures on the forge runner are partly this I have not read; its logs would say `Address already in use`. ## Fix proposed The invariant as written, kept without a gap: the `TestNode` binds its store's listener once and holds it for its whole life; each launch serves on a duplicate of it (`try_clone` of the standard listener, made a tokio one), so a stopped worker lets go of its duplicate only and the port stays the node's. No port number is ever bound a second time. And a worker task that ends with an error fails the test that is waiting on its node, with that error, instead of leaving it to its timeout. It touches `src/runs/harness.rs` alone, no production code. I commission it now as a fix of the documented invariant; say if you would rather have it differently. ## Landed 08:15:25Z 11-18: main f68f8f26 The node's half is done (the developer's 0012788d picked on d748ed8d; t's whole check set on t-testing green, run r7fea383c25, 8 passed and 5 answered from earlier runs in 324 s). A `TestNode` binds its store's socket once, when it is made, and holds it until it is dropped; each launch serves on a duplicate (`try_clone`, made a tokio listener in the node's runtime). The new test `runs::engine::tests::a_stopped_nodes_store_port_is_still_its_own_and_its_restart_serves_on_it` stops a node, finds its port refused to another bind while it is down, restarts it on the same port and passes a check on it. That it fails on the old code is reasoned, not run: there the stop closed the listener, so the bind succeeded. One thing it changes for a test: the held socket stays listening while a node is down, so a connect to a stopped node waits in the backlog instead of being refused. No test stops a node another node fetches from; the wave test restarts one, which is down for its runtime's shutdown only. Still open here: a worker task that ends with an error is only printed and the test waits to its timeout. The developer's survey of which tests see a worker end with an error on purpose was cut short (its local test run damaged the laptop's shared clone, issue 101), so that half is not built. **09:01Z 11-18:** the forge workflow's first run to complete on a main that holds the fix is green: run 1579 on 86a540fc (test, fmt, clippy; runs 1575 to 1578 were cancelled by later pushes). One run says nothing of a failure that came about one run in fifteen; it shows the new test and the three restarting tests pass on the forge's runner.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
tilo/t#100
No description provided.