Commit d96d81e
committed
fix(nodedb-cluster): eliminate 30s-per-peer stalls during cluster join
Two independent but compounding issues caused cluster join to hang for
tens of seconds on every startup when seeds were not yet bootstrapped:
1. The QUIC RPC timeout only covered the response-read phase. A
handshake attempt against an unreachable or not-yet-listening peer
blocked for the transport's internal idle timeout (~30 s), not the
configured RPC timeout. In a 5-node race where every non-bootstrapper
seed redirects to another non-bootstrapper, this multiplied to
(N-1) × 30 s of wasted wall time per join attempt.
Fixed by wrapping the entire send_rpc_to_addr operation — handshake,
stream open, write, and read — in a single tokio::time::timeout
bounded by self.rpc_timeout, and extracting the inner work into
send_rpc_to_addr_inner so the public interface stays clean.
2. The seed work-list was a Vec used as a stack (pop), so seed order
was unspecified. Under the single-elected-bootstrapper rule the
lexicographically smallest address is the one peer that can actually
answer during the initial race; hitting it last meant exhausting
timeouts against every other seed first.
Fixed by sorting seeds at the start of the join loop so the
designated bootstrapper surfaces first, and switching to VecDeque
so leader redirects are pushed to the front (push_front / pop_front)
and consumed before unvisited seeds.1 parent 06d3b07 commit d96d81e
2 files changed
Lines changed: 38 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
150 | 165 | | |
151 | 166 | | |
152 | 167 | | |
153 | 168 | | |
154 | | - | |
| 169 | + | |
155 | 170 | | |
156 | 171 | | |
157 | 172 | | |
| |||
172 | 187 | | |
173 | 188 | | |
174 | 189 | | |
175 | | - | |
| 190 | + | |
176 | 191 | | |
177 | 192 | | |
178 | 193 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
270 | 278 | | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
271 | 287 | | |
272 | 288 | | |
273 | 289 | | |
| |||
295 | 311 | | |
296 | 312 | | |
297 | 313 | | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
| 314 | + | |
304 | 315 | | |
305 | 316 | | |
306 | 317 | | |
| |||
0 commit comments