From d30c267292283c38c68abe27b164b52d1a99ffe9 Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Fri, 3 Apr 2026 11:14:27 +0200 Subject: [PATCH] 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) --- .../controller/RouteCatalogController.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/cameleer3-server-app/src/main/java/com/cameleer3/server/app/controller/RouteCatalogController.java b/cameleer3-server-app/src/main/java/com/cameleer3/server/app/controller/RouteCatalogController.java index abdaffb4..bc3c28b6 100644 --- a/cameleer3-server-app/src/main/java/com/cameleer3/server/app/controller/RouteCatalogController.java +++ b/cameleer3-server-app/src/main/java/com/cameleer3/server/app/controller/RouteCatalogController.java @@ -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 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 allAppIds = new LinkedHashSet<>(agentsByApp.keySet()); + allAppIds.addAll(routesByApp.keySet()); + List catalog = new ArrayList<>(); - for (var entry : agentsByApp.entrySet()) { - String appId = entry.getKey(); - List agents = entry.getValue(); + for (String appId : allAppIds) { + List agents = agentsByApp.getOrDefault(appId, List.of()); // Routes Set routeIds = routesByApp.getOrDefault(appId, Set.of());