Scope query snapshots to current database on Azure SQL DB (#857)#861
Merged
erikdarlingdata merged 1 commit intodevfrom Apr 18, 2026
Merged
Scope query snapshots to current database on Azure SQL DB (#857)#861erikdarlingdata merged 1 commit intodevfrom
erikdarlingdata merged 1 commit intodevfrom
Conversation
On Azure SQL Database, logins without access to master can't resolve cross-database rows returned by sys.dm_exec_requests, which caused the Live Snapshot button and the query snapshots collector to error in D365FO-style environments (reported by @TrudAX in #857 after PR #858). BuildQuerySnapshotsQuery now takes an isAzureSqlDatabase flag and emits AND der.database_id = DB_ID() only when true. Boxed SQL Server, MI, and elastic pool behavior is unchanged. The Live Snapshot button path gets the flag through a new ServerTab constructor parameter wired from the cached ServerConnectionStatus.SqlEngineEdition. Co-Authored-By: Claude Opus 4.7 (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.
Summary
Follow-up to #858. @TrudAX reported that the Live Snapshot button still errored on his D365FO Azure SQL Database after the collector fallback shipped. Root cause:
sys.dm_exec_requestscan surface rows for databases the login can't resolve (typically master-scoped activity), and the subsequentOUTER APPLYs tosys.dm_exec_sql_text/sys.dm_exec_text_query_planblow up.On Azure SQL DB, scoping the query snapshots result set to the current database is both correct and sufficient —
sys.dm_exec_requestson Azure SQL DB is already per-connection and the user DB is the only DB the login is guaranteed to access.BuildQuerySnapshotsQuerytakes a newisAzureSqlDatabaseflag and emitsAND der.database_id = DB_ID()only when trueSqlEngineEditionfrom the cachedServerConnectionStatus(already did — just added the flag derivation)ServerTabconstructor parameter wired fromMainWindowVerified on a fresh Azure SQL DB (
GP_S_Gen5) —DB_ID()(no args) returns the current DB, the scoped query runs cleanly, and activity from the current DB shows up in Live Snapshot.Test plan
dotnet build Lite/PerformanceMonitorLite.csproj -c Debug— 0 errors🤖 Generated with Claude Code