From 12d413ff90e7754722f737c2b7290412c1637206 Mon Sep 17 00:00:00 2001 From: Nathan Flurry Date: Sun, 30 Jun 2024 21:06:48 -0700 Subject: [PATCH] fix(mm): skip prewarming ats if no nodes booted --- .../ops/version-prepare/src/prewarm_ats.rs | 4 +- .../mm/ops/lobby-runtime-aggregate/src/lib.rs | 52 +++++++++---------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/svc/pkg/mm-config/ops/version-prepare/src/prewarm_ats.rs b/svc/pkg/mm-config/ops/version-prepare/src/prewarm_ats.rs index 7ab09e70a..894f70c29 100644 --- a/svc/pkg/mm-config/ops/version-prepare/src/prewarm_ats.rs +++ b/svc/pkg/mm-config/ops/version-prepare/src/prewarm_ats.rs @@ -72,7 +72,9 @@ pub async fn prewarm_ats_cache( let mut vlan_ips_in_region = vlan_ips.iter().filter(|row| row.datacenter_id == region_id); let vlan_ip_count = vlan_ips_in_region.clone().count() as i64; - ensure!(vlan_ip_count != 0, "no ats servers found"); + if vlan_ip_count == 0 { + continue; + } // Pass artifact URLs to the job let parameters = prewarm_ctx diff --git a/svc/pkg/mm/ops/lobby-runtime-aggregate/src/lib.rs b/svc/pkg/mm/ops/lobby-runtime-aggregate/src/lib.rs index 9a1c5d6c8..ff4afabda 100644 --- a/svc/pkg/mm/ops/lobby-runtime-aggregate/src/lib.rs +++ b/svc/pkg/mm/ops/lobby-runtime-aggregate/src/lib.rs @@ -41,32 +41,32 @@ async fn handle( let region_rows = sql_fetch_all!( [ctx, RegionRow] " - SELECT - namespace_id, - region_id, - SUM( - CASE - -- Lobbies stopped during the query window - WHEN stop_ts > $2 AND stop_ts <= $3 THEN - stop_ts - GREATEST(create_ts, $2) - -- Lobbies created during the query window, these may already be stopped after query_end - WHEN create_ts > $2 AND create_ts <= $3 THEN - LEAST(stop_ts, $3) - create_ts - -- Lobbies still running that overlap with the query window - WHEN stop_ts IS NULL AND create_ts <= $3 THEN - $3 - create_ts - ELSE 0 - END - ) AS total_time - FROM db_mm_state.lobbies AS OF SYSTEM TIME '-5s' - WHERE namespace_id = ANY($1) - AND ( - (stop_ts > $2 AND stop_ts <= $3) - OR (create_ts > $2 AND create_ts <= $3) - OR (stop_ts IS NULL AND create_ts <= $3) - ) - GROUP BY namespace_id, region_id - ", + SELECT + namespace_id, + region_id, + SUM_INT( + CASE + -- Lobbies stopped during the query window + WHEN stop_ts > $2 AND stop_ts <= $3 THEN + stop_ts - GREATEST(create_ts, $2) + -- Lobbies created during the query window, these may already be stopped after query_end + WHEN create_ts > $2 AND create_ts <= $3 THEN + LEAST(stop_ts, $3) - create_ts + -- Lobbies still running that overlap with the query window + WHEN stop_ts IS NULL AND create_ts <= $3 THEN + $3 - create_ts + ELSE 0 + END + ) AS total_time + FROM db_mm_state.lobbies AS OF SYSTEM TIME '-5s' + WHERE namespace_id = ANY($1) + AND ( + (stop_ts > $2 AND stop_ts <= $3) + OR (create_ts > $2 AND create_ts <= $3) + OR (stop_ts IS NULL AND create_ts <= $3) + ) + GROUP BY namespace_id, region_id + ", &namespace_ids, query_start, query_end,