Skip to content

Commit 08a292c

Browse files
Fix collection health overflow and query stats DOP type mismatch
- collection_health view: cast duration_ms and rows_collected to bigint before AVG/SUM to prevent arithmetic overflow after 7 days of data - collection_health C# reader: use Convert.ToInt64 for avg_duration_ms, update model property from int to long - query_stats reader: min_dop/max_dop columns are bigint in the table but reader called GetInt16() — changed to Convert.ToInt16(GetValue()) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 79a0234 commit 08a292c

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

Dashboard/Models/CollectionHealthItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class CollectionHealthItem
1919
public decimal FailureRatePercent { get; set; }
2020
public long TotalRuns7d { get; set; }
2121
public long FailedRuns7d { get; set; }
22-
public int AvgDurationMs { get; set; }
22+
public long AvgDurationMs { get; set; }
2323
public long TotalRowsCollected7d { get; set; }
2424
}
2525
}

Dashboard/Services/DatabaseService.QueryPerformance.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,8 +1014,8 @@ USE HINT('ENABLE_PARALLEL_PLAN_PREFERENCE')
10141014
AvgRows = reader.IsDBNull(24) ? null : reader.GetInt64(24),
10151015
MinRows = reader.IsDBNull(25) ? null : reader.GetInt64(25),
10161016
MaxRows = reader.IsDBNull(26) ? null : reader.GetInt64(26),
1017-
MinDop = reader.IsDBNull(27) ? null : reader.GetInt16(27),
1018-
MaxDop = reader.IsDBNull(28) ? null : reader.GetInt16(28),
1017+
MinDop = reader.IsDBNull(27) ? null : Convert.ToInt16(reader.GetValue(27)),
1018+
MaxDop = reader.IsDBNull(28) ? null : Convert.ToInt16(reader.GetValue(28)),
10191019
MinGrantKb = reader.IsDBNull(29) ? null : reader.GetInt64(29),
10201020
MaxGrantKb = reader.IsDBNull(30) ? null : reader.GetInt64(30),
10211021
TotalSpills = reader.IsDBNull(31) ? 0 : reader.GetInt64(31),

Dashboard/Services/DatabaseService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ CASE health_status
176176
FailureRatePercent = reader.IsDBNull(4) ? 0m : Convert.ToDecimal(reader.GetValue(4), CultureInfo.InvariantCulture),
177177
TotalRuns7d = reader.IsDBNull(5) ? 0L : Convert.ToInt64(reader.GetValue(5), CultureInfo.InvariantCulture),
178178
FailedRuns7d = reader.IsDBNull(6) ? 0L : Convert.ToInt64(reader.GetValue(6), CultureInfo.InvariantCulture),
179-
AvgDurationMs = reader.IsDBNull(7) ? 0 : Convert.ToInt32(reader.GetValue(7), CultureInfo.InvariantCulture),
179+
AvgDurationMs = reader.IsDBNull(7) ? 0 : Convert.ToInt64(reader.GetValue(7), CultureInfo.InvariantCulture),
180180
TotalRowsCollected7d = reader.IsDBNull(8) ? 0L : Convert.ToInt64(reader.GetValue(8), CultureInfo.InvariantCulture)
181181
});
182182
}

install/47_create_reporting_views.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ WITH
6969
(
7070
CASE
7171
WHEN cl.collection_status = N'SUCCESS'
72-
THEN cl.duration_ms
72+
THEN CAST(cl.duration_ms AS bigint)
7373
ELSE NULL
7474
END
7575
),
@@ -78,8 +78,8 @@ WITH
7878
(
7979
CASE
8080
WHEN cl.collection_status = N'SUCCESS'
81-
THEN cl.rows_collected
82-
ELSE 0
81+
THEN CAST(cl.rows_collected AS bigint)
82+
ELSE CAST(0 AS bigint)
8383
END
8484
)
8585
FROM config.collection_log AS cl
@@ -157,7 +157,7 @@ SELECT
157157
),
158158
total_runs_7d = cs.total_runs,
159159
failed_runs_7d = cs.failed_runs,
160-
avg_duration_ms = CONVERT(integer, cs.avg_duration_ms),
160+
avg_duration_ms = CONVERT(bigint, cs.avg_duration_ms),
161161
total_rows_collected_7d = cs.total_rows_collected
162162
FROM collector_stats AS cs
163163
LEFT JOIN recent_failures AS rf

0 commit comments

Comments
 (0)