concurrency - SQL Server 2008: Getting deadlocks... without any locks -


I'm currently using something on a SQL Server 2008 database. More specifically, I have a JDBC application Which uses hundreds of concurrent threads to execute thousands of tasks, each of which runs the following query on the database:

  Update with table A where the rowID = '123'   

However, when I set the separation level to more than READ_UNCOMMITTED I'm getting deadlock a ton of errors (SQL exception in 1205). This happens even when I set the row locking, table locking, and unique lock signal! And even in snapshot isolation, which does not use lock, I still get deadlock errors.

When this happens, I had run a trace through the SQL Profiler to get the Deadlock graph, but it was not too much use. This affair was connected to the "thread pool", which was linked to hundreds of other processes. You can see it here:

Is there any indication why this is happening? I have been trying to understand it in the last few days. My current hypothesis is that it is something related to the worker thread available in my DB example, the amount of available memory, or some actual query level locks.

Thank you!

You have to face a more esoteric animal: what a resource deadlock you have, because All workers () are busy. In return, busy workers block the possibilities that occur on ordinary locks by the victim.

To take home I'm looking for two lessons here:

1) Post by you The update is trying to go parallel. If the update you posted is absolutely fine, then that means there is one more thing: no index on rowId .

2) You bounced on the upper ceiling from the setting. There is no wonder that you misuse the thread in the client (to execute thousands of thousands of concurrent threads) and multiply it in the server due to unwanted parallel.

A sensible design async execution () will actually be used on async connections () and will use a pool of pending requests so that it does not exceed a certain limit. More likely, however, is that you will pass a whole batch of update values ​​and then in the same statement will arrange whole sets or rows, will be batched. I think all of my links are there. For the Net, not for Java, I do not care, you can lose yourself the equivalent Java functionality.

It is interesting that when you discovered such a latent standoff, it only shows because your design is good, it is useless ....

Comments