Skip to content

Fix OverflowException on wait stats decimal division (Issue #395)#396

Merged
erikdarlingdata merged 2 commits intodevfrom
fix/decimal-overflow-395
Mar 3, 2026
Merged

Fix OverflowException on wait stats decimal division (Issue #395)#396
erikdarlingdata merged 2 commits intodevfrom
fix/decimal-overflow-395

Conversation

@erikdarlingdata
Copy link
Owner

Summary

  • SQL Server's decimal arithmetic produces decimal(38,24) when dividing decimal(19,4) by bigint, exceeding .NET's System.Decimal ~29-digit limit
  • Wraps all 20 per-second rate and avg-ms-per-wait division results in CAST(... AS decimal(18, 4)) to bound the result type
  • Affects wait stats, signal wait stats, lock wait stats, and execution count per-second calculations
  • Reported by @philippe-cloquet with XTP_PREEMPTIVE_TASK (227M ms wait time)

Files changed

  • Dashboard/Services/DatabaseService.ResourceMetrics.cs (16 instances)
  • Dashboard/Services/DatabaseService.QueryPerformance.cs (4 instances)

Test plan

  • Open Resource Metrics > Wait Stats with large cumulative wait types
  • Toggle wait type checkboxes — no OverflowException
  • Verify chart data displays correctly

Closes #395

🤖 Generated with Claude Code

erikdarlingdata and others added 2 commits March 3, 2026 09:29
…395

SQL Server's decimal arithmetic produces decimal(38,24) when dividing
decimal(19,4) by bigint, which exceeds .NET System.Decimal's ~29 digit
limit. Wrap all 20 per-second rate and avg-ms-per-wait division results
in CAST(... AS decimal(18, 4)) to bound the result type.

Affects wait stats, signal wait stats, lock wait stats, and execution
count per-second calculations.

Closes #395

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Same decimal(19,2) / bigint => decimal(38,21) overflow risk in the
poison wait delta query used by the Server Health Overview page.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit 6dd3a91 into dev Mar 3, 2026
3 checks passed
@erikdarlingdata erikdarlingdata deleted the fix/decimal-overflow-395 branch March 3, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant