Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Deadlock - why is this happening?

$
0
0

Hi all. Hoping someone can help explain this...

I have a Header table that is part of a Header/Detail set. The Header table has an AFTER INSERT trigger on it. When a new record is inserted into Header, the trigger fires and checks if the record type = XYZ, if it does, it calls a stored procedure which does the following:

  1. Insert combined data from the Header and Detail records into a History table
  2. Delete the original data from the header table
  3. Delete the original data from the detail table

I've found that if I rapidly insert records into the Header/Detail tables, I sometimes hit a deadlock. This is not good, because it is realistic that a bunch of these inserts may be hitting the table at once, and they need to complete.

I used Profiler to get the deadlock graph (picture attached), and it seems that the deadlocked resource is the clustered...


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>