Commit 61d6a03
refactor: replace SQL JOIN gating with BatchQuerier + per-handler hc fetch
``DeploymentRepository.get_routes_by_statuses`` (which carried the
``DeploymentRevisionRow.model_definition`` and ``SessionRow.status``
JOINs and the in-memory ``RouteHealthCheckFilter`` post-filter) is
split into two narrower entry points so handlers carry the cost of the
data they actually need:
- ``search_route_datas(querier: BatchQuerier)`` returns bare
``RouteData`` from ``RoutingRow`` alone; the coordinator builds a
``BatchQuerier`` from each handler's ``RouteTargetStatuses`` (now
``lifecycle``/``health``/optional list ``traffic``) at the call site
with ``RouteConditions``.
- ``fetch_health_check_configs(revision_ids)`` returns a per-revision
``ModelHealthCheck | None`` map, called from
``HealthCheckRouteHandler``, ``AppProxySyncRouteHandler``,
``RouteHealthObserver``, and ``RouteExecutor.check_running_routes``
to gate their per-route behaviour.
``RouteHealthCheckFilter``, ``RouteHandler.health_check_filter()`` and
every override are removed; ``RouteSessionData`` is dropped and
``RouteData.session_id`` becomes a direct field again.
In ``check_running_routes``, the ``(RouteData, ModelHealthCheck)`` pairs
are bundled into a private ``_RouteWithHealthCheck`` frozen dataclass
that flows down through ``_ensure_health_records`` and
``_initialize_health_records``; ``_populate_replica_info`` now also
mutates ``replica_host``/``replica_port`` on the in-memory routes so
the newly populated rows fall through to the single Phase-4 record
init. ``sync_appproxy`` self-fetches ``session_statuses`` instead of
relying on the dropped SQL join.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent c25b818 commit 61d6a03
28 files changed
Lines changed: 397 additions & 469 deletions
File tree
- src/ai/backend/manager
- data/deployment
- repositories/deployment
- db_source
- types
- sokovan/deployment/route
- handlers
- observer
- tests/unit/manager
- repositories/deployment
- sokovan/deployment
- executor
- route
- executor
- handlers
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
256 | | - | |
| 256 | + | |
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
| 261 | + | |
273 | 262 | | |
274 | 263 | | |
275 | 264 | | |
| |||
Lines changed: 54 additions & 87 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | 74 | | |
76 | 75 | | |
77 | 76 | | |
78 | 77 | | |
79 | | - | |
80 | 78 | | |
81 | 79 | | |
82 | 80 | | |
| |||
178 | 176 | | |
179 | 177 | | |
180 | 178 | | |
181 | | - | |
182 | 179 | | |
183 | 180 | | |
184 | 181 | | |
| |||
204 | 201 | | |
205 | 202 | | |
206 | 203 | | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | 204 | | |
236 | 205 | | |
237 | 206 | | |
| |||
1009 | 978 | | |
1010 | 979 | | |
1011 | 980 | | |
1012 | | - | |
1013 | | - | |
1014 | | - | |
1015 | | - | |
1016 | | - | |
| 981 | + | |
1017 | 982 | | |
1018 | 983 | | |
1019 | 984 | | |
1020 | 985 | | |
1021 | 986 | | |
1022 | | - | |
| 987 | + | |
1023 | 988 | | |
1024 | 989 | | |
1025 | 990 | | |
| |||
1029 | 994 | | |
1030 | 995 | | |
1031 | 996 | | |
1032 | | - | |
| 997 | + | |
1033 | 998 | | |
1034 | 999 | | |
1035 | 1000 | | |
| |||
1616 | 1581 | | |
1617 | 1582 | | |
1618 | 1583 | | |
1619 | | - | |
| 1584 | + | |
1620 | 1585 | | |
1621 | | - | |
1622 | | - | |
| 1586 | + | |
1623 | 1587 | | |
1624 | | - | |
1625 | | - | |
| 1588 | + | |
1626 | 1589 | | |
1627 | | - | |
1628 | | - | |
1629 | | - | |
1630 | | - | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
1631 | 1593 | | |
1632 | 1594 | | |
1633 | | - | |
1634 | | - | |
1635 | | - | |
1636 | | - | |
1637 | | - | |
1638 | | - | |
1639 | | - | |
1640 | | - | |
1641 | | - | |
1642 | | - | |
1643 | | - | |
1644 | | - | |
1645 | | - | |
1646 | | - | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
1647 | 1612 | | |
1648 | | - | |
1649 | | - | |
1650 | | - | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
1651 | 1633 | | |
1652 | | - | |
1653 | | - | |
1654 | | - | |
1655 | | - | |
1656 | | - | |
1657 | | - | |
1658 | | - | |
1659 | | - | |
1660 | | - | |
1661 | | - | |
1662 | | - | |
1663 | | - | |
1664 | | - | |
1665 | | - | |
1666 | | - | |
1667 | | - | |
1668 | | - | |
1669 | | - | |
1670 | | - | |
1671 | | - | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
1672 | 1638 | | |
1673 | | - | |
| 1639 | + | |
| 1640 | + | |
1674 | 1641 | | |
1675 | 1642 | | |
1676 | 1643 | | |
| |||
Lines changed: 23 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
71 | 70 | | |
72 | 71 | | |
73 | 72 | | |
74 | | - | |
75 | 73 | | |
76 | 74 | | |
77 | 75 | | |
| |||
629 | 627 | | |
630 | 628 | | |
631 | 629 | | |
632 | | - | |
| 630 | + | |
633 | 631 | | |
634 | | - | |
635 | | - | |
| 632 | + | |
636 | 633 | | |
637 | | - | |
638 | | - | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
639 | 652 | | |
640 | | - | |
| 653 | + | |
641 | 654 | | |
642 | 655 | | |
643 | 656 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
20 | | - | |
21 | 19 | | |
Lines changed: 1 addition & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
20 | | - | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
| |||
60 | 58 | | |
61 | 59 | | |
62 | 60 | | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | 61 | | |
72 | 62 | | |
73 | 63 | | |
74 | 64 | | |
75 | 65 | | |
76 | 66 | | |
77 | | - | |
| 67 | + | |
78 | 68 | | |
79 | 69 | | |
80 | 70 | | |
| |||
84 | 74 | | |
85 | 75 | | |
86 | 76 | | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | 77 | | |
94 | 78 | | |
95 | 79 | | |
| |||
0 commit comments