Hi,
I appreciate that Profiler output is required to diagnose deadlocks but this is a general question and I don't currently have the ability to set profiler flags on a customer's SQL Server so...
I have scheduled tasks which run overnight when the target SQL Server database is unused. They are run by my Windows application which connects to SQL Sever using ADO / a database connection string. My application is not multi-threaded so I'm positive that each SQL command is issued after the other has returned and not in parallel. For better or worse (I expect I'll get hammered for this!) I'm running the whole process as a single transaction, which is not best practice but means that if anything fails I can easily roll the whole database back to its start point, which is the desired functionality).
At seemingly random points during the transaction, and only in about one in 20 (or more) runs I'm getting deadlocks reported, such as:
"CADORecordset Error
Code = 80004005
Code meaning = Unspecified error
Source = Microsoft OLE DB Provider for SQL Server
Description = Transaction (Process ID 51) was deadlocked on thread | communication buffer resources with another process and has been chosen as the deadlock victim. Rerun the transaction."
I'm assuming this error is caused by process A locking record 1 and waiting for record 2 while process B concurrently locks record 2 and is waiting for record 1.
My application uses a number of different SQL statement(SELECT, UPDATE, MERGE) and records the SQL it issued that failed with this error so I know there is no consistent SQL statement which causes it. Also, this problem only occurs in one customer. All other customers do not appear to suffer the problem.
Does this mean the deadlock must (almost certainly) be caused by another process (i.e. application) running on the server? Or is my assumption incorrect, the assumption being "if my application issues SQL commands sequentially then how can it cause a deadlock?"?
Thanks!
Pete
Creator of the Software Update Wizard... add update over the web to your app with a single line of code!