SQL Server unvisible locks

lifeisdao 65 Reputation points
2023-05-22T19:14:21.32+00:00

I caught events blocked_process_report and tried to analyze what was blocked and why. The xml data I saw the following information:

<data name="blocked_process">
		<value>
			<blocked-process-report monitorLoop="797267">
				<blocked-process>
					<process id="process20758057c28" taskpriority="0" logused="20000" waittime="15874" schedulerid="2" kpid="25520" status="suspended" spid="650" sbid="0" ecid="2" priority="0" trancount="0" lastbatchstarted="2023-05-22T16:43:25.330" lastbatchcompleted="2023-05-22T16:43:25.330" lastattention="1900-01-01T00:00:00.330" clientapp="83 Server" hostname="024" hostpid="39912" isolationlevel="read committed (2)" xactid="454142046462" currentdb="5" currentdbname="XXX" lockTimeout="20000" clientoption1="671230048" clientoption2="128056">
						<executionStack>
							<frame line="1" stmtstart="950" stmtend="17300" sqlhandle="0x02000000fd5a0839e4850791d608df1f6698c2cd53e6609a0000000000000000000000000000000000000000"/>
							<frame line="1" sqlhandle="0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"/>
						</executionStack>
						<inputbuf>  (@P1 numeric(10),@P2 numeric(10),@P3 numeric(10),@P4 datetime2(3),@P5 nvarchar(4000),@P6 numeric(10),@P7 datetime2(3),@P8 nvarchar(4000),@P9 numeric(10),@P10 numeric(10),@P11 varbinary(16),@P12 varbinary(16),@P13 nvarchar(4000),@P14 varbinary(16),@P15 varbinary(16),@P16 varbinary(16),@P17 varbinary(16),@P18 varbinary(16),@P19 varbinary(16),@P20 varbinary(16),@P21 varbinary(16),@P22 varbinary(16),@P23 varbinary(16),@P24 varbinary(16),@P25 varbinary(16),@P26 varbinary(16))SELECT DISTINCT  ... </inputbuf>
					</process>
				</blocked-process>
				<blocking-process>
					<process status="runnable" spid="650" sbid="0" ecid="4" priority="0" trancount="0" lastbatchstarted="2023-05-22T16:43:25.330" lastbatchcompleted="2023-05-22T16:43:25.330" lastattention="1900-01-01T00:00:00.330" clientapp="83 Server" hostname="024" hostpid="39912" isolationlevel="read committed (2)" xactid="454142046462" currentdb="5" currentdbname="XXX" lockTimeout="20000" clientoption1="671230048" clientoption2="128056">
						<executionStack>
							<frame line="1" stmtstart="950" stmtend="17300" sqlhandle="0x02000000fd5a0839e4850791d608df1f6698c2cd53e6609a0000000000000000000000000000000000000000"/>
							<frame line="1" sqlhandle="0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"/>
						</executionStack>
						<inputbuf>  (@P1 numeric(10),@P2 numeric(10),@P3 numeric(10),@P4 datetime2(3),@P5 nvarchar(4000),@P6 numeric(10),@P7 datetime2(3),@P8 nvarchar(4000),@P9 numeric(10),@P10 numeric(10),@P11 varbinary(16),@P12 varbinary(16),@P13 nvarchar(4000),@P14 varbinary(16),@P15 varbinary(16),@P16 varbinary(16),@P17 varbinary(16),@P18 varbinary(16),@P19 varbinary(16),@P20 varbinary(16),@P21 varbinary(16),@P22 varbinary(16),@P23 varbinary(16),@P24 varbinary(16),@P25 varbinary(16),@P26 varbinary(16))SELECT DISTINCT ...</inputbuf>
					</process>
				</blocking-process>
			</blocked-process-report>
		</value>
	</data>

So as there two threads of process the one of them blocked other, because only difference between them is ecid.
How can I proceed 
investigation of this issue? I guess that it is some kind of latch but I don't know the best way to understand root cause for blocking
SQL Server Other
{count} votes

Accepted answer
  1. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2023-05-22T21:53:55.1366667+00:00

    Blocking can be due to other things than locking. In this case, since the spid is the same for both and only the ecid is different, it is a matter of a parallel plan where the work is unbalanced between the thread. The "blocked" process is waiting for the other thread to complete.

    I think you should only investigate this issue, if there are real complaints about performance. It is quite likely that the query can benefit from tuning, but most workloads have query than can be tuned. And as long as users are happy, our employers or customers may prefer that we spend our time on other tasks.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.