Fix SQL view/analyzer defects from Fable code review (chunk 6)#1107
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_group—install/26LEFT(deadlock_group, CHARINDEX(',', ...) - 1)throws "invalid length parameter passed to the LEFT function" when there's no comma (CHARINDEXreturns 0 →LEFT(x, -1)).deadlock_groupis 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_summarynever reports CPU_CRITICAL on Linux —install/47The
CPU_CRITICALbranch tested rawtotal_cpu_utilization, which is NULL on SQL Server on Linux. Added the #1048ISNULL(total_cpu_utilization, sqlserver_cpu_utilization)fallback the other CPU branches already use.Validation
Both scripts
CREATE OR ALTERcleanly on SQL2016, exit 0.Remaining view/FinOps findings — flagged for follow-up (deeper rewrites)
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".UNDER_PROVISIONED(tells you to scale up) and rarely finds real savings — the anti-FinOps direction.top_memory_consumers: SUMs a point-in-time gauge (pages_kb) over a 15-min window (~3× inflation; absolute thresholds fire early).query_stats_summarymixes MAX across different plans of a hash;query_store_regressionsfilters 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