Repository navigation
Bootstrap a cluster peer session only once - #8593
Conversation
There was a problem hiding this comment.
Superseded by the review of
435e826c.
This review, of d50d7779
💬 Approved with comments — A small, correct fix to how a peer session bootstraps. The only note, an INFO, is that no deterministic regression test covers the crash.
Findings: 1 info (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📋 Code Quality: 💬 1 info
The fix is correct: the bootstrap is taken once in the Session constructor and reused. No regression test comes with it.
Recommendation: 💬 Optional Nits
- [INFO] No regression test covers bootstrapping on a failed session. (
src/workerd/server/factory/worker-factory-rpc.c++:214)
View full review
Correctness: no problems found.
worker-factory-impl.h: members are declaredconnection, thenrpcSystem, thenbootstrap, so they are built and destroyed in a safe order.worker-factory-rpc.c++: both call sites cast the stored client. The types they get are the same as before.- No other code under
factory/callsrpcSystem.bootstrap().
Testing: the crash is only covered statistically, by cluster-cron-test runs. A deterministic test would guard against it coming back.
✅ All other checks passed
📝 Documentation: ✅ LGTM
The new comment on Session::bootstrap explains why the capability is obtained only once.
Reviewed commit: d50d7779
d50d777 to
435e826
Compare
There was a problem hiding this comment.
Superseded by the review of
66f8bdbb.
This review, of 435e826c
✅ Approved — A small, correct fix so a peer session bootstraps only once, now covered by a deterministic regression test. No problems found.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
No security concerns in this change.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md updates needed.
📋 Code Quality: ✅ LGTM
SessiontakesrpcSystem.bootstrap()once, and its members are built and destroyed in a safe order (connection,rpcSystem,bootstrap).- Both call sites use the stored client, and their types are unchanged.
- The new
kj_testfails the first call by dropping the peer's end of the pipe while that call is out. It then checks that an actor obtained afterwards fails withDISCONNECTEDinstead of throwing from a second bootstrap.
⚡ Performance: ✅ LGTM
Taking the bootstrap once per session also saves a bootstrap round trip for each later actor.
📝 Documentation: ✅ LGTM
The comment on Session::bootstrap explains why the capability is obtained only once.
Reviewed commit: 435e826c
ry
left a comment
There was a problem hiding this comment.
[AI] LGTM. Taking the bootstrap once is the usual capnp pattern, and the test is deterministic. A follow-up worth considering: the node aborted because the bridge declares rpc_client_debug_actor as returning KjOwn<RpcClient>, so any C++ exception there kills the process. Declaring it -> Result<KjOwn<RpcClient>> would turn the next surprise into a failed call.
435e826 to
66f8bdb
Compare
|
Done in 66f8bdb: |
There was a problem hiding this comment.
Superseded by the review of
b23c2f7f.
This review, of 66f8bdbb
💬 Approved with comments — The fix is correct and the error now reaches the caller through ?. The only remaining note is an INFO about two comments that still describe the Rust caller as infallible.
Findings: 1 info (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📝 Documentation: 💬 1 info
Two comments still describe the Rust caller as unable to fail.
Recommendation: 💬 Optional Nits
- [INFO] Comment still says the Rust caller cannot fail and aborts, but
rpc_client_debug_actornow returnsResult. (src/workerd/server/factory/worker-factory-impl.h:264)
View full review
worker-factory-impl.h:263-264andworker-factory-rpc-test.c++:51-52say the Rust caller cannot fail and would abort. Sincerpc_client_debug_actornow returnsResultandroutepropagates the error, that is no longer true.
✅ All other checks passed
🔒 Security: ✅ LGTM
No security concerns in this change.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md updates needed.
📋 Code Quality: ✅ LGTM
Sessiontakes the peer's bootstrap once, when it is constructed, and both call sites use that stored capability.rpc_client_debug_actornow returnsResult, andClusterNode::routepropagates the error with?.routealready returnscrate::Result<Owner>, and other bridge calls inactor.rsuse the same pattern.- The new
kj_testis deterministic: it fails the session's connection while a call is still out, then checks that a later actor's calls fail asDISCONNECTED.
⚡ Performance: ✅ LGTM
Taking the bootstrap once per session also saves a bootstrap round trip for each later actor.
Reviewed commit: 66f8bdbb
A peer session bootstrapped again for each Durable Object it reached
through the debug port's getActor. Once the session's connection had
failed with calls out, such a bootstrap started a new RPC connection
over the same TwoPartyVatNetwork, which still counted the failed one
as busy. capnp's check of that threw from the bootstrap call itself
("expected idle != this->idle"), not as a disconnect of its calls,
and rpc_client_debug_actor(), which the bridge declared as unable to
fail, aborted the node.
* A session takes the peer's bootstrap once, as it connects, and
every capability obtained over it starts from that one. On a failed
connection, calls on it fail as disconnected, which the caller
treats as the session being down
* The bridge declares rpc_client_debug_actor() as returning a Result,
so an exception it throws fails the request being routed to the
peer instead of aborting the node
* A worker-factory test gets an actor over a session that the peer
reads and never answers, closes the peer's end, and checks that an
actor obtained afterwards fails its calls as disconnected. Without
the fix, its getActor throws "expected idle != this->idle"
cluster-cron-test hit this in 2 of 120 runs, in "a cron occurrence
does not run again on an owner whose clock lags", with the cluster
lease fixes and tokio running between busy KJ turns applied, changes
that are not on main yet. On main it did not show in 80 runs, but
nothing there keeps a session from bootstrapping after a failure.
66f8bdb to
b23c2f7
Compare
There was a problem hiding this comment.
✅ Approved — The fix is correct and covered by a deterministic regression test, and the stale comment noted in the earlier review has been fixed. No findings remain.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
No security concerns in this change.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md updates needed.
📋 Code Quality: ✅ LGTM
The bootstrap is taken once per session, after the RPC system it depends on is built. Both call sites use the stored capability. The new test is deterministic.
⚡ Performance: ✅ LGTM
Taking the bootstrap once per session also saves a bootstrap round trip for each later actor. Holding one extra capability per session costs nothing meaningful.
📝 Documentation: ✅ LGTM
The comments in worker-factory-impl.h and in the test now describe only capnp's behaviour, which matches the code.
Reviewed commit: b23c2f7f
A cluster node could abort after a peer connection failed. A peer
session bootstrapped again for each Durable Object it reached through
getActor. Once the connection had failed with calls still out, such abootstrap started a new RPC connection over the same
TwoPartyVatNetwork, which still counted the failed one as busy.capnp's check threw from the bootstrap call itself ("expected idle !=
this->idle"), and
rpc_client_debug_actor(), which the Rust sidedeclares as unable to fail, aborted the node.
capability obtained over it starts from that one. On a failed
connection, calls on it fail as disconnected, which the caller
already treats as the session being down.
worker-factory-rpc-testfails a session's connection with agetActorstill unanswered, then gets another actor over thesession and checks that its calls fail as disconnected. Without the
fix it throws the same "expected idle != this->idle".
cluster-cron-testhit this in 2 of 120 runs with the pending clusterlease and event-loop changes applied, and 0 of 160 with this fix. On
main it did not show in 80 runs, but nothing there keeps a session from
bootstrapping after a failure.