Skip to content

Updates_20260901 - Permission to Come Aboard - #862

Merged
erikdarlingdata merged 11 commits into
mainfrom
dev
Aug 31, 2026
Merged

erikdarlingdata merged 11 commits into
mainfrom
dev

Conversation

@erikdarlingdata

Copy link
Copy Markdown
Owner

Updates_20260901Permission to Come Aboard.

All ten procs move to .9, version date 20260901.

sp_LogHunter stops asking the wrong question

sp_LogHunter refused to run for anyone who was not sysadmin, which was never the permission it actually needed. xp_readerrorlog can be granted with GRANT EXECUTE, and an account holding that grant read the log perfectly well while IS_SRVROLEMEMBER(N'sysadmin') answered no and the proc bailed out.

  • The gate is now HAS_PERMS_BY_NAME(N'master.dbo.xp_readerrorlog', N'OBJECT', N'EXECUTE') — the permission the procedure uses, asked about directly. The error message names it too, so a failure tells you what to grant.
  • sp_enumerrorlogs, which enumerates the archived logs, is a separate problem: it checks membership in securityadmin itself, and no GRANT substitutes for that. Rather than failing the whole run on error 27219, sp_LogHunter now catches it, reads the current log — which xp_readerrorlog can still do — and says so.

Verified on the reporter's exact permission set, which also proved nothing else in the procedure needs elevation. (#858, #859)

sp_QuickieStore

@find_parameter_sensitive reworked against a production fleet (#854). Ranking is now work-weighted: coefficient of variation alone is scale-blind, and a 3ms→60ms swing was out-ranking a 2s→40s one. On one tenant the window CPU represented by the surfaced top 15 went from 295s to 4,170s. Also: the hash include/ignore lists are honored inside the mode, mixed swings fills a classification gap that left 25 of 162 surfaced shapes with a blank verdict, ratio displays cap at 9999+ instead of printing 2850350x, and the summary now distinguishes "no waits" from "wait capture is off" rather than silently omitting the column.

Two wait-accounting fixes that both understated nothing and overstated everything. @wait_filter matched waits from all of Query Store history rather than the interval asked for (#852), and the wait sort orders counted across all of history the same way (#850).

New log and total log sort orders (#819, thanks @ReeceGoding).

sp_PerfCheck

@database_name narrowed the summary but not the per-file I/O detail, so a filtered run still returned files from every database on the instance — 16 rows where 2 were asked for. The filter is now applied at the sys.dm_io_virtual_file_stats call itself, matching how the Azure SQL DB path already worked, instead of in a WHERE clause that the detail query never had. (#856, #860 — thanks @jbelina)

erikdarlingdata and others added 11 commits August 4, 2026 00:55
…ry (#850)

The #plan_ids_with_total_waits inserts joined query_store_runtime_stats
to query_store_wait_stats on plan_id alone, so the date range only
decided which plans qualified while the wait numbers came from every
interval the plan ever ran in. The 'total waits' branch also multiplied
that all-history total by the number of in-window runtime stats rows.
Joining on runtime_stats_interval_id and execution_type scopes waits to
the qualified rows.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…al-join

Fix wait sort orders counting waits across all of Query Store history (#850)
The #wait_filter populate aggregated query_store_wait_stats with no
date restriction, so queries whose waits happened entirely outside
the requested window still passed the filter, and the TOP was ranked
by all-history wait totals. Joining to query_store_runtime_stats on
(plan_id, runtime_stats_interval_id, execution_type) and filtering
last_execution_time by the date range matches the semantics of the
main where clause and the wait sort order joins from #851.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…rval-scope

Fix @wait_filter matching waits from all of Query Store history (#852)
…t-order

sp_QuickieStore: added the 'log' and 'total log' sort orders
* add database filtering to metrics gathering queries #856

* formatting changes per PR #856

* remove extra whitespace before @SQL

* found more whitespace differences

* yet more whitespace differences, I think I got them all this time

* sp_PerfCheck: scope the IO stall DMV call, drop trailing whitespace

Pass @filter_database_id into sys.dm_io_virtual_file_stats for @io_sql
the way @file_io_sql already does, so the DMV returns one database's
files instead of every file on the instance for the WHERE to discard.
The WHERE branch becomes 1 = 1 for the same reason the Azure branch is.

Correct the trailing comment: with @database_name set the result is one
database, tempdb included only when that is the database asked for.

---------

Co-authored-by: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com>
* Add override for system admin check (@skip_sysadmin_check) #858

* switch to can_read check provided in feature comment #858

* sp_LogHunter: read the current log when archives cannot be enumerated

Swapping the sysadmin test for a real permission check gets a caller
with EXECUTE on xp_readerrorlog past line 178, and then sp_enumerrorlogs
fails them with 27219 because it wants securityadmin. A GRANT does not
help - it checks the role itself - and HAS_PERMS_BY_NAME reports 1 for
it regardless, so it cannot be gated the same way.

Enumerating archives is a convenience. Catch 27219, fall back to the
current log, and say so.

---------

Co-authored-by: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Updates_20260901 release prep: version bumps
@erikdarlingdata
erikdarlingdata merged commit a771ca2 into main Aug 31, 2026
10 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.

3 participants