-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Conversation
SET LOCK_TIMEOUT 1000 when APPLY sys.dm_exec_query_statistics_xml to prevent mutex issues. Set GitHub BrentOzarULTD#3210
Set LOCK_TIMEOUT
|
||
/* GitHub #3210 */ | ||
SET @StringToExecute = N' | ||
SET LOCK_TIMEOUT 1000 ' + @StringToExecute + N' OUTER APPLY sys.dm_exec_query_statistics_xml(s.session_id) qs_live '; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 beSET 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
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
…On Tue, Jan 31, 2023 at 9:11 AM Brent Ozar ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In sp_BlitzFirst.sql
<#3221 (comment)>
:
> @@ -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 ';
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.
—
Reply to this email directly, view it on GitHub
<#3221 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APNFWAUTV2CKOB5I6ARJZADWVEMSVANCNFSM6AAAAAAULPAZFM>
.
You are receiving this because you authored the thread.Message ID:
<BrentOzarULTD/SQL-Server-First-Responder-Kit/pull/3221/review/1277270261@
github.com>
|
Sorry about that! I misunderstood the code. Just a gentle suggestion for next time - comments sure do help when folks are trying to understand your code. ;-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that! I misunderstood the code. Just a gentle suggestion for next time - comments sure do help when folks are trying to understand your code. ;-)
SET LOCK_TIMEOUT 1000 when APPLY sys.dm_exec_query_statistics_xml to prevent mutex issues. Set GitHub #3210