I got a deadlock problem and I found that it's caused by two stored procedures that is called by different threads (2 called web services).
- Insert sp that insert data in X table.
- Delete sp that delete data in X table.
Moreover, I got result that told me about deadlock happened in non-unique and non-clustered index of X table. Do you have any idea for solve this problem?
Update
From Read/Write deadlock, I think it error because of the following statements.
- In insert statement, it get id(clustered index) and then non-clustered index.
- In delete statment, it get non-clustered index before id.
So, I need to select id for delete statment like the following statement.
SELECT id FROM X WITH(NOLOCK) WHERE [condition]
PS. Both stored procedures are called in transaction.
Thanks,