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_BlitzWho returns multiple records for some session IDs #1089

Closed
nirst opened this issue Aug 31, 2017 · 7 comments
Closed

sp_BlitzWho returns multiple records for some session IDs #1089

nirst opened this issue Aug 31, 2017 · 7 comments

Comments

@nirst
Copy link

nirst commented Aug 31, 2017

Do you want to request a feature or report a bug?
Bug
Script: sp_BlitzWho
Version 5.4 - June 05, 2017 onwards

What is the current behavior?
Since this version, sp_BlitzWho returns multiple records for some session IDs due to the cross apply to tempdb allocations. This returns multiple rows when sessions have multiple exec_context_ids in sys.dm_db_task_space_usage.

What is the expected behavior?
A single row per session - I don't think the cross apply is working as expected.

SQL Version
I've seen this issue on Microsoft SQL Server 2008 R2 (SP3) - 10.50.6220.0 (X64)

@BlitzErik
Copy link
Contributor

Hello!

I haven't come across this. Can you add some more details to this the next time it happens? We don't join to exec context id, and we're already summing these values

image

I'm not calling you crazy, because we've run into multiple rows returned bugs in the past, just want to make sure i'm focusing on the right part of the code.

If it's as simple as adding a TOP 1 to the CROSS APPLY and you want to code and test it, feel free.

Thanks!

@nirst
Copy link
Author

nirst commented Aug 31, 2017

Nope - you're absolutely right. I'm definitely seeing multiple rows though and its only for sessions where there are multiple exec_context_ids but perhaps that was a red herring - I put 2 and 2 together based on the 5th June version being the first instance where this cropped up. I'll see if I can narrow it down further.

@nirst
Copy link
Author

nirst commented Aug 31, 2017

OK the issue seems to be on line 261:

image

The join creates multiple lines when a session has multiple records in dm_db_task_space_usage (e.g. multiple exec_content_ids).

@BlitzErik
Copy link
Contributor

Hahaha, well the first thing is that left join shouldn't be there.

All the information for that part for the query comes from here:

image

Up in the select list, we use the bits from the outer apply.

image

Lemme crank out a quick version for you to test.

@BlitzErik
Copy link
Contributor

Alright, this is probably going to need a TOP 1 in it, but incremental changes are probably smart.

Can you test out the version here and let me know if anything is wonky?

https://raw.githubusercontent.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/933fa6a7343dd6cdc04ac5db5f97631d67e8ed1e/sp_BlitzWho.sql

@nirst
Copy link
Author

nirst commented Sep 1, 2017

Yep that worked a treat!

@BlitzErik
Copy link
Contributor

Awesome! I'm going to leave this open in case you spot anything else, or in case anyone else comes along with the same issue. It will likely go into the next FRK release.

Thanks!

@BlitzErik BlitzErik added this to the 2017-10 milestone Sep 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants