Commit 454502a
fix(mcp): bound session disconnect so a wedged host close cannot hang teardown
_disconnect_targets submitted every per-host Target.close() to a
ContextExecutor and used concurrent.futures.wait(..., timeout=45) to bound
the wait -- but the `with ContextExecutor()` block's __exit__ runs
shutdown(wait=True), which re-joins every worker regardless of that timeout.
A paramiko close that wedges (dead peer, no RST) keeps its worker thread
alive, so shutdown(wait=True) blocked forever and close() never returned;
under http this hung the registry idle-sweep awaiting it and leaked the
thread, contradicting the docstring's "bounded wait" promise.
Drop the context-manager exit for the bound: shut the pool down explicitly
with wait=False (cancel_futures=True) after the timed wait, log any host
that overran the budget, and abandon its close (the worker thread leaks, but
teardown always returns). The 45s bound is now a named module constant and
_disconnect_targets takes a `timeout` argument so the behaviour is testable
without a 45s wait.
Adds a revert-verified regression test: a host whose close() blocks forever
no longer stalls _disconnect_targets -- the healthy host is still closed, the
stuck one is logged, and every template's host group is cleared.
Resolves finding openSUSE#10 from the recent code review.1 parent d56530c commit 454502a
3 files changed
Lines changed: 98 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
240 | 247 | | |
241 | 248 | | |
242 | 249 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
106 | 114 | | |
107 | 115 | | |
108 | 116 | | |
| |||
553 | 561 | | |
554 | 562 | | |
555 | 563 | | |
556 | | - | |
| 564 | + | |
557 | 565 | | |
558 | 566 | | |
559 | 567 | | |
560 | 568 | | |
561 | | - | |
562 | | - | |
563 | | - | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
564 | 587 | | |
565 | 588 | | |
566 | 589 | | |
| |||
575 | 598 | | |
576 | 599 | | |
577 | 600 | | |
578 | | - | |
579 | | - | |
580 | | - | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
581 | 615 | | |
582 | 616 | | |
583 | 617 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
451 | 451 | | |
452 | 452 | | |
453 | 453 | | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
454 | 504 | | |
455 | 505 | | |
456 | 506 | | |
| |||
0 commit comments