Repository navigation
Commit 9027fe3
fix: reload TOML config per source instead of reconnecting every source (#461)
* fix: reload TOML config per source instead of reconnecting every source
The config watcher used to call `disconnect()` on every source and then
reconnect them all whenever `dbhub.toml` changed. In-flight queries finished,
but until the slowest one did, every new call on every source failed with
"Cannot use a pool after calling end on the pool", including sources the
edit never touched (#454, problem 1).
The reload is now a diff against the last applied source list:
- Unchanged sources are left alone and keep their pools.
- New sources are connected (or registered lazily), removed ones are
disconnected, and edited ones are reconnected, one at a time.
- Rollback is per source: a changed source whose new config fails to connect
is restored to its previous config; a new source that fails is skipped.
Tools referencing a source that is not live are dropped from the registry
so one bad source cannot take the rest down.
- Source order follows the file so the first entry stays the default.
`ConnectorManager` gains `addSource()`, `removeSource()` and
`reorderSources()`; `disconnect()` is unchanged and still used at shutdown.
Refs #454
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HPXjjvWtnhfENJ7FWHoyfH
* fix: close IAM refresh race and keep previous tools for rolled-back sources
Two review findings on the per-source reload:
- An IAM refresh already running when removeSource() was called could finish
its reconnect after the removal and put the source back (or clobber a
same-id replacement), then re-arm its timer. Track the in-flight refresh
per source and have removeSource() await it, and guard the refresh's
reconnect and re-arm on the source still being the registered one.
- A source rolled back to its previous config was still given the new file's
tool definitions, which were written against the config that did not
apply. The watcher now keeps the previous tools for rolled-back ids and
uses the new tools only for sources that are live under the new config.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HPXjjvWtnhfENJ7FWHoyfH
* fix: validate the registry before applying a reload and close tunnels on every connect failure
Review findings on the per-source reload:
- The tool registry validates more than the TOML loader (custom tool
parameters, duplicate tool names), so it could throw after the source diff
had already been applied, leaving the manager on the new sources with the
old registry and a stale diff baseline. The watcher now builds a registry
from the new file before touching any connection, so a bad file is
rejected whole. The one remaining conflict, a rolled-back source's
previous tools clashing with the new file's tools, takes that source
offline instead of serving it with the wrong tools. The diff baseline is
updated as soon as the sources are committed.
- connectSource() closed the SSH tunnel only when connector.connect()
rejected. A failure between tunnel establishment and that call left the
tunnel in the map, and a later retry would orphan it. The cleanup now
covers everything after the tunnel is up.
- The reload log reported success even when a changed source had been rolled
back; the degraded message now counts rolled-back sources too.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HPXjjvWtnhfENJ7FWHoyfH
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 28f99f0 commit 9027fe3
5 files changed
Lines changed: 811 additions & 153 deletions
File tree
- docs/config
- src
- connectors
- __tests__
- utils
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
| 35 | + | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
393 | 418 | | |
394 | 419 | | |
395 | 420 | | |
| |||
510 | 535 | | |
511 | 536 | | |
512 | 537 | | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
0 commit comments