"Transaction (Process ID 56) was deadlocked on lock resources with another"
I have a process that (at night) takes a large chunk of data in the form of a linq2sql query and dumps this as XML (sitemaps). My problem is that I'm sometimes getting:
System.Data.SqlClient.SqlException:
Transaction (Process ID XX) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
This query is readonly and is not necessary to be "transaction safe". Can I writ开发者_Python百科e a process like this to avoid the exception?
EDIT:
Basically the code is:
foreach(Record record in MyDataContext.FatTableWithRecords) //about 50' records
{
//produce some XML (dumped to file when max 50' records or 10MB large)
}
The code for the query would help debug your particular problem, but you could also look at using sql jobs and some of the sql server functionality like xmlauto
and transaction isolation level read uncommitted
to handle your needs.
精彩评论