fix: route catalog missing routes after server restart
After server restart, auto-healed agents register with empty routeIds. The catalog only looked at agent registry for routes, so routes and counts disappeared. Now merges route IDs from ClickHouse stats_1m_route into the catalog. Also includes apps that only exist in ClickHouse data (no agent currently registered). Routes and exchange counts survive server restarts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -103,6 +103,16 @@ public class RouteCatalogController {
|
||||
log.warn("Failed to query route exchange counts: {}", e.getMessage());
|
||||
}
|
||||
|
||||
// Merge route IDs from ClickHouse stats into routesByApp.
|
||||
// After server restart, auto-healed agents have empty routeIds, but
|
||||
// ClickHouse still has execution data with the correct route IDs.
|
||||
for (var countEntry : routeExchangeCounts.entrySet()) {
|
||||
String[] parts = countEntry.getKey().split("/", 2);
|
||||
if (parts.length == 2) {
|
||||
routesByApp.computeIfAbsent(parts[0], k -> new LinkedHashSet<>()).add(parts[1]);
|
||||
}
|
||||
}
|
||||
|
||||
// Per-agent TPS from the last minute
|
||||
Map<String, Double> agentTps = new LinkedHashMap<>();
|
||||
try {
|
||||
@@ -117,11 +127,13 @@ public class RouteCatalogController {
|
||||
// AggregatingMergeTree table may not exist yet
|
||||
}
|
||||
|
||||
// Build catalog entries
|
||||
// Build catalog entries — merge apps from agent registry + ClickHouse data
|
||||
Set<String> allAppIds = new LinkedHashSet<>(agentsByApp.keySet());
|
||||
allAppIds.addAll(routesByApp.keySet());
|
||||
|
||||
List<AppCatalogEntry> catalog = new ArrayList<>();
|
||||
for (var entry : agentsByApp.entrySet()) {
|
||||
String appId = entry.getKey();
|
||||
List<AgentInfo> agents = entry.getValue();
|
||||
for (String appId : allAppIds) {
|
||||
List<AgentInfo> agents = agentsByApp.getOrDefault(appId, List.of());
|
||||
|
||||
// Routes
|
||||
Set<String> routeIds = routesByApp.getOrDefault(appId, Set.of());
|
||||
|
||||
Reference in New Issue
Block a user