Skip to content

Widen collector columns to match DMV documentation#552

Merged
erikdarlingdata merged 1 commit intodevfrom
fix/audit-column-type-mismatches
Mar 13, 2026
Merged

Widen collector columns to match DMV documentation#552
erikdarlingdata merged 1 commit intodevfrom
fix/audit-column-type-mismatches

Conversation

@erikdarlingdata
Copy link
Owner

Summary

  • Full audit of all collector table schemas against Microsoft DMV documentation
  • Widened 6 SQL Server columns and 2 Lite DuckDB columns that were narrower than documented DMV types
  • Added idempotent upgrade script (02_widen_audit_columns.sql) for existing installations

SQL Server fixes

Table Column Old New DMV Source
cpu_scheduler_stats total_work_queue_count int bigint dm_os_schedulers.work_queue_count
cpu_scheduler_stats total_active_parallel_thread_count int bigint dm_resource_governor_workload_groups
cpu_scheduler_stats system_memory_state_desc nvarchar(120) nvarchar(256) dm_os_sys_memory
waiting_tasks resource_description nvarchar(1000) nvarchar(3072) dm_os_waiting_tasks
database_size_stats recovery_model_desc nvarchar(12) nvarchar(60) sys.databases
database_size_stats volume_mount_point nvarchar(256) nvarchar(512) dm_os_volume_stats

Lite fixes

Table Column Old New Reason
tempdb_stats total_sessions_using_tempdb INTEGER BIGINT COUNT_BIG result, removed (int) narrowing cast
session_stats connection_count INTEGER BIGINT COUNT_BIG result, switched to Convert.ToInt64

Files changed

  • install/02_create_tables.sql — fresh install definitions
  • install/06_ensure_collection_table.sql — ensure procedure definitions
  • install/52_collect_database_size_stats.sql — Azure SQL DB CONVERT width
  • Lite/Database/Schema.cs — DuckDB schema
  • Lite/Services/RemoteCollectorService.TempDb.cs — narrowing cast fix
  • Lite/Services/RemoteCollectorService.SessionStats.cs — narrowing cast fix
  • upgrades/2.2.0-to-2.3.0/02_widen_audit_columns.sql — idempotent upgrade

Test plan

  • Upgrade script tested on sql2022 — all 6 columns widened
  • Idempotency verified — second run is no-op
  • Dashboard builds clean (0 errors)
  • Lite builds clean (0 errors)

🤖 Generated with Claude Code

Full audit of all collector tables against Microsoft DMV docs found
6 SQL Server columns and 2 Lite columns narrower than documented types:

SQL Server:
- cpu_scheduler_stats: total_work_queue_count, total_active_parallel_thread_count (int -> bigint)
- cpu_scheduler_stats: system_memory_state_desc (nvarchar(120) -> nvarchar(256))
- waiting_tasks: resource_description (nvarchar(1000) -> nvarchar(3072))
- database_size_stats: recovery_model_desc (nvarchar(12) -> nvarchar(60))
- database_size_stats: volume_mount_point (nvarchar(256) -> nvarchar(512))

Lite (DuckDB):
- tempdb_stats: total_sessions_using_tempdb (INTEGER -> BIGINT, removed narrowing cast)
- session_stats: connection_count (INTEGER -> BIGINT, COUNT_BIG result)

Also fixes Azure SQL DB collector CONVERT(nvarchar(12),...) -> nvarchar(60)
for recovery_model_desc.

Idempotent upgrade script tested on sql2022.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit 943ddc9 into dev Mar 13, 2026
7 checks passed
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