-
Notifications
You must be signed in to change notification settings - Fork 63
Drop sys.dm_os_schedulers from memory_stats on Azure SQL DB (#857) #876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,14 @@ Use sys.dm_os_sys_info committed_target_kb/committed_kb as approximations. | |
| Azure MI (edition 8) HAS dm_os_sys_memory, sql_memory_model_desc, and behaves like on-prem. */ | ||
| bool isAzureSqlDb = serverStatus.SqlEngineEdition == 5; | ||
|
|
||
| /* | ||
| * Azure SQL Database in an elastic pool (e.g. D365FO tenants) enforces | ||
| * VIEW SERVER PERFORMANCE STATE on sys.dm_os_schedulers regardless of | ||
| * the login's DB-scoped grants, so we skip the schedulers subquery on | ||
| * Azure SQL DB and report current_workers_count as NULL. The rest of | ||
| * the row — memory sizes from sys.dm_os_sys_info and the perf counters | ||
| * — succeeds for contained DB users. See #857. | ||
| */ | ||
| string query = isAzureSqlDb | ||
| ? @" | ||
| SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; | ||
|
|
@@ -46,7 +54,7 @@ Azure MI (edition 8) HAS dm_os_sys_memory, sql_memory_model_desc, and behaves li | |
| buffer_pool_mb = CONVERT(decimal(18,2), pc_buffer.cntr_value / 1024.0), | ||
| plan_cache_mb = CONVERT(decimal(18,2), pc_plan.cntr_value * 8.0 / 1024.0), | ||
| max_workers_count = osi.max_workers_count, | ||
| current_workers_count = w.current_workers | ||
| current_workers_count = CONVERT(int, NULL) | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Downstream UX consequence worth noting (not a blocker for this PR): Generated by Claude Code |
||
| FROM sys.dm_os_sys_info AS osi | ||
| CROSS JOIN | ||
| ( | ||
|
|
@@ -73,12 +81,6 @@ FROM sys.dm_os_performance_counters | |
| WHERE counter_name = N'Cache Pages' | ||
| AND object_name LIKE N'%:Plan Cache%' | ||
| ) AS pc_plan | ||
| CROSS JOIN | ||
| ( | ||
| SELECT current_workers = SUM(active_workers_count) | ||
| FROM sys.dm_os_schedulers | ||
| WHERE status = N'VISIBLE ONLINE' | ||
| ) AS w | ||
| OPTION(RECOMPILE);" | ||
| : @" | ||
| SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: comment says "report current_workers_count as NULL", but the reader at
Memory.cs:164coercesIsDBNull(11) ? 0 : reader.GetInt32(11), so the value landing in DuckDBmemory_stats.current_workers_countis0, not NULL. A maintainer who reads only this block will be misled about what downstream consumers see. Consider tightening to something like "…SQL returns NULL; the reader coerces it to 0 before the appender, so DuckDB sees 0."Generated by Claude Code