Skip to content

Fix SQL view/analyzer defects from Fable code review (chunk 6)#1107

Merged
erikdarlingdata merged 1 commit into
devfrom
feature/code-review-sql-views
Jun 11, 2026
Merged

Fix SQL view/analyzer defects from Fable code review (chunk 6)#1107
erikdarlingdata merged 1 commit into
devfrom
feature/code-review-sql-views

Conversation

@erikdarlingdata

Copy link
Copy Markdown
Owner

SQL view/analyzer fixes from the Fable code review (chunk 6 of 7). Validated on SQL2016; 2017–2025 need your version testing.

Fixes

[MEDIUM→crash] Deadlock analyzer aborts on a comma-less deadlock_groupinstall/26
LEFT(deadlock_group, CHARINDEX(',', ...) - 1) throws "invalid length parameter passed to the LEFT function" when there's no comma (CHARINDEX returns 0 → LEFT(x, -1)). deadlock_group is free text from sp_BlitzLock, so any format drift aborts the whole analyzer transaction — taking the blocking aggregation down with it. Now falls back to the whole string when there's no comma.

[MEDIUM] daily_summary never reports CPU_CRITICAL on Linuxinstall/47
The CPU_CRITICAL branch tested raw total_cpu_utilization, which is NULL on SQL Server on Linux. Added the #1048 ISNULL(total_cpu_utilization, sqlserver_cpu_utilization) fallback the other CPU branches already use.

Validation

Both scripts CREATE OR ALTER cleanly on SQL2016, exit 0.

Remaining view/FinOps findings — flagged for follow-up (deeper rewrites)

  • [HIGH] 46 expensive_queries_today: the Query Store branch drops multi-interval queries (the busiest ones); SUMs cumulative DMV counters across snapshots (N× inflation — siblings use MAX); and has no date filter despite "today".
  • [HIGH] 54 FinOps efficiency: flags healthy idle servers UNDER_PROVISIONED (tells you to scale up) and rarely finds real savings — the anti-FinOps direction.
  • [HIGH] 47 top_memory_consumers: SUMs a point-in-time gauge (pages_kb) over a 15-min window (~3× inflation; absolute thresholds fire early).
  • [MEDIUM] 46/47 query_stats_summary mixes MAX across different plans of a hash; query_store_regressions filters on CPU regression but ranks/scores by duration with unweighted averages; 50 TokenAndPerm 1 GB threshold compared per NUMA node not per clerk; 12 blocking-chain view created unconditionally against a conditionally-created base view.

These are aggregation-logic rewrites I'd want your eyes on (and real version testing), so I left them rather than guess.

🤖 Generated with Claude Code

…hunk 6)

- 26 blocking_deadlock_analyzer: LEFT(deadlock_group, CHARINDEX(',',...) - 1)
  throws "invalid length parameter" whenever deadlock_group has no comma (it's
  free-text from sp_BlitzLock, format can drift), aborting the whole analyzer
  transaction and losing the run's blocking aggregation too. Now falls back to
  the whole string when there's no comma (COALESCE(NULLIF(CHARINDEX,0)-1, LEN)).
- 47 daily_summary: the CPU_CRITICAL test used raw total_cpu_utilization, which
  is NULL on SQL Server on Linux, so daily_summary could never report
  CPU_CRITICAL there. Added the #1048 ISNULL(total, sqlserver) fallback that the
  other CPU branches already use.

Validation: both scripts CREATE OR ALTER cleanly on SQL2016, exit 0. 2017-2025
need your version testing.

Remaining view/FinOps findings flagged for follow-up (deeper rewrites): 46
expensive_queries_today drops multi-interval Query Store queries, SUMs cumulative
DMV counters (N x inflation), and has no date filter despite "today"; 54 FinOps
efficiency flags healthy idle servers UNDER_PROVISIONED (anti-savings direction);
47 top_memory_consumers SUMs a point-in-time gauge over 15 min (~3x); 46/47
query_stats_summary MAX-across-plans and query_store_regressions filter/rank
mismatch; 50 TokenAndPerm threshold per NUMA node not per clerk; 12 blocking-chain
view created unconditionally against a conditional base view.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit cf04fb0 into dev Jun 11, 2026
@erikdarlingdata erikdarlingdata deleted the feature/code-review-sql-views branch June 11, 2026 05:55
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