sql server 2012 - Upsert Causes Deadlocks -
i have following stored procedure:
create procedure [dbo].[upsert2] ( @id varchar(20), @status varchar(50), @price varchar(20), @volume varchar(20), @currency varchar(20), @instrumentid varchar(20), @seqid varchar(20), @entrydate datetime) set transaction isolation level read uncommitted; begin transaction merge trades using (select @id 'id',@status 'status',@price 'price',@volume 'volume',@currency 'currency',@instrumentid 'instrumentid',@seqid 'seqid',@entrydate 'entrydate') query on trades.id = query.id , trades.instrumentid = query.instrumentid , trades.seqid = query.seqid when matched update set trades.status = query.status, trades.price = query.price, trades.volume = query.volume, trades.span = query.span, trades.currency = query.currency, trades.instrumentid = query.instrumentid, trades.seqid = query.seqid, trades.entrydate = query.entrydate when not matched insert (status,price,volume,span,currency,instrumentid,seqid,entrydate) values (query.status,query.price,query.volume,query.span,query.currency,query.instrumentid,query.seqid,query.entrydate); commit
this procedure called 4 diffrent processes, run @ same time, wich causes produce deadlocks , fail calls, there wrong procedure can fix cure deadlocks, have no more ideas how fix it.
Comments
Post a Comment