Waiting for idle_blocker which we cannot find

Cyprexx IT
Cyprexx IT used Ask the Experts™
on
We have been seeing long wait times at random intervals throughout the day.  When we dig into these waits, it always seems they are being caused by an idle blocker (as we have discovered through DPA as well as some extended events.)  The problem is, once we realize this has happened, it's already too late.  The SPID that was causing the idle blocking is closed and we cannot determine what was running.  We have some extended events set up that give us a bit of information about the SPID (such as the call stack, duration, wait_resource, and wait_type) but none of this tells me exactly what stored procedure, query, or other process was running.  

Does anyone have a recommended way to store all information about past SPIDs, or any other advice on how to deal with this going forward?  At this point, I'm not worried about necessarily finding out what's happened in the past (though that is welcomed as well,) but how to get this information stored going forward so I can refer back to it.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
This is a very good piece from Brent Ozar on identifying the blocking processes with a server side trace.  See the section that begins with:
  Scripts to use the Blocked Process Report

https://www.brentozar.com/sql/locking-and-blocking-in-sql-server/

You could put it into place now, to help identify the problem, and then re-enable the trace in the future, if any blocking related problems recur.

Author

Commented:
I have actually read through this article, and it does have some really good info.  I have turned on the Blocked Process Report, but the article itself is only useful if you know the blocking is going to occur, which I never do.  It specifically tells you to make sure you turn off the blocked process report at the end, so the scripts in here won't really help me since I have to know when it's happening to utilize this.
Commented:
Yes, I've read that, too, but have also used it successfully when leaving it running throughout the day -- to identify the blocking problem, as you are trying to do.  The server side traces are much lighter than the profiler, and when they are defined explicitly to only collect on the block events, then the overhead is minimal.

I do understand your concerns, though, so here are two more that I've used that are defined w/extended events.  Again, they are defined solely for the blocked process events, so the overhead is minimal.

https://www.sqlskills.com/blogs/erin/capture-blocking-information-with-extended-events-and-the-blocked-process-report/
https://blogs.msdn.microsoft.com/nav/2015/01/16/using-sql-server-extended-events-to-produce-a-blocked-process-report/
Expert Spotlight: Joe Anderson (DatabaseMX)

We’ve posted a new Expert Spotlight!  Joe Anderson (DatabaseMX) has been on Experts Exchange since 2006. Learn more about this database architect, guitar aficionado, and Microsoft MVP.

Author

Commented:
Excellent, I will set up the Extended Event and leave it on.  As long as the overhead is minimal (which I agree with you, it certainly should be, or no worse that the other extended events I have running currently,) it shouldn't be a problem.  I was just concerned about the fact the first article was explicit on the fact it should be turned off in the end.  

As far as our situation, it seems to occur once every 10-14 days.  If it was daily, or hourly, I would have had no issue with leaving it on, but I wasn't sure about leaving it on for several weeks.  Once I get some information on what's causing this, I will be sure to turn it off again.  Thank you!

Author

Commented:
Excellent responses.  Thank you!

Commented:
Completely my pleasure.  In a similar situation recently, I have left blocking process session on for weeks at a time, and had no related problems.  Just be sure to check status and output intermittently, and be sure nothing is getting away from you.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial