Skip to content
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

sp_BlitzFirst SET LOCK_TIMEOUT #3221

Merged
merged 2 commits into from
Feb 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions sp_BlitzFirst.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2293,8 +2293,9 @@ If one of them is a lead blocker, consider killing that query.'' AS HowToStopit,
CROSS APPLY sys.dm_exec_query_plan(r.plan_handle) AS qp ';

IF EXISTS (SELECT * FROM sys.all_objects WHERE name = 'dm_exec_query_statistics_xml')
SET @StringToExecute = @StringToExecute + N' OUTER APPLY sys.dm_exec_query_statistics_xml(s.session_id) qs_live ';

/* GitHub #3210 */
SET @StringToExecute = N'
SET LOCK_TIMEOUT 1000 ' + @StringToExecute + N' OUTER APPLY sys.dm_exec_query_statistics_xml(s.session_id) qs_live ';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Errr, that can't work. This puts SET LOCK_TIMEOUT in the middle of a query. Note what happens next in the query - it's an outer apply. That won't even compile.

You can see what I mean by trying to run:

SELECT * FROM sys.databases d
SET LOCK_TIMEOUT 1000
OUTER APPLY sys.dm_exec_query_statistics_xml(d.database_id) qs_live;

That doesn't even parse. So... with all due respect, I don't think you understand the problem you're trying to solve, so let's call this one off.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BrentOzar,

Can you please reopen this issue, or comment on my response?

Brent,

Are you sure? Look again. I added the SET LOCK_TIMEOUT 1000 before the
existing @StringToExecute, for exactly the reason that it already had data
in it.

So if @StringToExecute contained 'SELECT * FROM sys.databases d', the
result of the statement would be

SET LOCK_TIMEOUT 1000
SELECT * FROM sys.databases d
OUTER APPLY sys.dm_exec_query_statistics_xml(d.database_id) qs_live;

As I said, this is compiled and working.

Vince


SET @StringToExecute = @StringToExecute + N';

Expand Down