Note that there are some explanatory texts on larger screens.

plurals
  1. POMinimizing deadlocks with purposely contrived + highly concurrent transactions?
    primarykey
    data
    text
    <p>I'm currently working on benchmarking different isolation levels in SQL Server 2008 -- but right now I'm stuck on what seems to be a trivial deadlocking problem, but I can't seem to figure it out. Hopefully someone here can offer advice (I'm a novice to SQL)</p> <p>I currently have two types of transactions (to demonstrate dirty reads, but that's irrelevant):</p> <p>Transaction Type A: Select all rows from Table A.</p> <p>Transaction Type B: Set value 'cost' = 0 in all rows in Table A, then rollback immediately.</p> <p>I currently run a threadpool of 1000 threads and 10,000 transactions, where each thread randomly chooses between executing Transaction Type A and Transaction Type B. However, I'm getting a ton of deadlocks even with forced row locking.</p> <p>I assume that the deadlocks are occurring because of the row ordering of locks being acquired -- that is, if both Type A and Type B 'scan' table A in the same ordering, e.g. from top to bottom, such deadlocks cannot occur. However, I'm having trouble figuring out how to get SQL Server to maintain row ordering during SELECT and UPDATE statements. </p> <p>Any tips? First time poster to stackoverflow, so please be gentle :-)</p> <p>EDIT: The isolation level is purposely set to READ_COMMITTED to show that it eliminates dirty reads (and it does). Deadlocks only occur on any level equal to or higher than READ_COMMITTED; obviously no deadlocks occur on READ_UNCOMMITTED.</p> <p>EDIT 2: These transactions are being run on a fresh instance of AdventureWorks LT on SQL Server 2008R2.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload