![]() The query is a long-running report, which can run for several minutes.Data consistency is not as important for this particular query, but is extremely important for the application in general.I am using SQL Server 2008 with encryption enabled.After looking a little closer, the exception is thrown after the query execution, but while the result set was being fetched.Does this help? Other than the overhead of using snapshot isolation, what it the complication with SNAPSHOT isolation? NOLOCK is a very radical solution when a good alternative is available. There was nothing posted by the OP that indicated that the deadlocked process or the deadlocking process was a lengthy one. If having correct data is important, then you should avoid using NOLOCK. snapshot isolation has its own complications in a lengthy process. Originally posted by jholovacs[I won't disagree with you, but the NOLOCK hint should be an easy way to avoid deadlocks. I won't disagree with you, but the NOLOCK hint should be an easy way to avoid deadlocks. It would be much better to use SNAPSHOT isolation than to use a NOLOCK hint.There are many data consistency problems that can be caused by using a NOLOCK hint, including returning duplicate rows and failing to return rows that actually exist. SELECT TOP 1 w.FROM dbo.women wINNER JOIN dbo.inlaws i ON i.inlaw_id = w.parent_idWHERE i.net_worth > 10000000 AND i.status IN ('dead', 'dying') AND w.husband_id IS NULLORDER BY w.hotness_factor DESC You could use a dirty read hint:SELECT x.y, x.z from dbo.table x WITH (NOLOCK)That will pretty much prevent the possibility of deadlocking with a SELECT, unless you are joining to a view or table-valued function with some odd goings-on under the hood. I agree that Snapshot Isolation would not improve an inefficientcy. There's probably a process that's doing something extremely inefficiently with the update or insert.If that's the case then going to Snapshot Isolation mode is still just ignoring the warning signs of the other problem. The select then wouldn't be able to acquire a lock until that transaction / process had stopped doing it's thing.Ĭorrect me if I am wrong, but with Snapshot Isolation mode, the Select wouldn't even need to acquire the lock? quote: I presume that the select failed because the table was being updated or inserted into by some other process. The select then wouldn't be able to acquire a lock until that transaction / process had stopped doing it's thing.There's probably a process that's doing something extremely inefficiently with the update or insert.If that's the case then going to Snapshot Isolation mode is still just ignoring the warning signs of the other problem.Charlie = Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION select) can block writers.I believe a solution is to go to Snapshot Isolation mode (as long as you are 2005+), in which case I'd be curious how it helps you:(VS.80).aspx But it could force another query to wait because unlike in Oracle, readers (ie. But I can't see how a select on its own could cause a deadlock. ![]() Insert, delete, update)? If so, I could see it. Was it part of a transaction involving some kind of write operation (ie. You can use hints to get round the problem but that isn't good practice and is just hiding from the real issue.Presumably some other process was updating or inserting into the table that you were reading from.Ho many processes running on your database?Charlie = Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION You should find out which transaction was causing the deadlock. ![]() Rerun the transaction."Is this because the query joins multiple tables and requests shared locks on them in sequence somehow causing a deadlock with another query? Should I use query hints to avoid the deadlock or should I retry running the query? What's the recommended approach?Thanks. SQL Server threw the following exception while executing a SELECT-query:"Transaction (Process ID 54) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. How can a read-only query cause a deadlock? We've got lots of great SQL ServerĮxperts to answer whatever question you can come up with. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |