I have a lock problem, and I found that it was called by two stored procedures that are called by different threads (2 are called web services).
- Insert sps that insert data into table X.
- Delete sps that delete data in table X.
In addition, I got a result that told me about the deadlock that occurred in the unhistorical and non-clustered index of table X. Do you have an idea to solve this problem?
Update
From the Read / Write Deadlock , I think this is a mistake due to the following statements.
- In the insert statement, it gets the identifier (cluster index), and then the non-clustered index.
- In deletion status, it receives a non-clustered index before the identifier.
So, I need to select id to remove statment, as the next statement.
SELECT id FROM X WITH(NOLOCK) WHERE [condition]
PS. Both stored procedures are called in a transaction.
Thanks,
source
share