Skip to content

sp_BlitzLock - fix duplicate plans#3773

Open
Tisit wants to merge 2 commits intoBrentOzarULTD:devfrom
Tisit:sp_BlitzLock_DuplicatePlans
Open

sp_BlitzLock - fix duplicate plans#3773
Tisit wants to merge 2 commits intoBrentOzarULTD:devfrom
Tisit:sp_BlitzLock_DuplicatePlans

Conversation

@Tisit
Copy link
Contributor

@Tisit Tisit commented Dec 10, 2025

Fix for #3765 (or at least improvements)

Turns out there are many causes of this:

  • if there are many statements in procedure we need to use specific statement start and end columns, otherwise we get something close to cartesian join
  • We may get duplicate query plans in #deadlock_results -> I take just max query_xml and group by rest of the columns. Seemed easiest way to fix for me
  • one query can have deadlock on many different tables. This caused same SQL to be reported many times. At least that is my interpretation, because removing dow.object_name on line 4145 (which was unused anyway) and aggregating seemed to fix this particular problem.

In the environment where I saw all these problems the number of rows returned dropped from 10k+ to 60. Much more managable in my opinion.

Thanks

@BrentOzar
Copy link
Member

Hi! I didn't want you to think that I've forgotten about this, but the code complexity is pretty high, and Erik Darling also had qualms about accepting it, so I haven't worked through this.

Ideally, for me to accept this pull request, I'd want a demo reproduction script where I can walk through it, including building a couple of deadlocks, that will produce BAD results with the CURRENT version of sp_BlitzLock, and then GOOD results with YOUR version.

Is that something you could do? I ask because you seem to know how to reproduce the bug, which I don't.

@Tisit
Copy link
Contributor Author

Tisit commented Mar 12, 2026

Hi

EDIT: Scratch that. I was able to reproduce the third case, but now I see my PR is flawed. I will come back with better feeedback when I sort things out. Thanks for patience.

There are 3 cases where the duplicates may appear as I described in issue #3765. In there I have provided reproducer for first two. The third I find too complicated to reproduce. It's something I saw on one of the systems I ran sp_BlitzLock against and could test my changes there. What I could do is rollback part of the changes related to the third case. This makes the diff simpler. The third case remains unsolved for me, but I'm not going to die for it ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants