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

sp_BlitzFirst SET LOCK_TIMEOUT #3221

merged 2 commits into from
Feb 6, 2023

Conversation

sqlslinger
Copy link
Contributor

SET LOCK_TIMEOUT 1000 when APPLY sys.dm_exec_query_statistics_xml to prevent mutex issues. Set GitHub #3210

SET LOCK_TIMEOUT 1000 when APPLY sys.dm_exec_query_statistics_xml to prevent mutex issues.  Set GitHub BrentOzarULTD#3210

/* 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

@BrentOzar BrentOzar closed this Jan 31, 2023
@sqlslinger
Copy link
Contributor Author

sqlslinger commented Jan 31, 2023 via email

@BrentOzar
Copy link
Member

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. ;-)

@BrentOzar BrentOzar reopened this Feb 6, 2023
Copy link
Member

@BrentOzar BrentOzar left a 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. ;-)

@BrentOzar BrentOzar merged commit 8dc35bc into BrentOzarULTD:dev Feb 6, 2023
@BrentOzar BrentOzar added this to the 2023-01 Release milestone Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants