![]() ![]() With gap-locks deadlocks are mathematically impossible to predict (since you have no guarantee for independent keys having specific values anyway) The other kind of deadlock is practically impossible to avoid: given sufficiently high transaction volume and any transaction isolation level above 'read committed' (so from 'repeatable read' to 'serializable') transactions use gap-locks. That said, if you look at the relational mapping of transactions, it is mathematically possible to create a systems where intrinsic structural deadlocks won't happen, if you control all queries and isolation levels. There should always be a wait before retrying, because, obviously, if the retry starts before the transaction A (that caused transaction B to deadlock) completes, you're just creating a bigger and bigger traffic-jam of locked resources that will hold locks on larger extents promoting more deadlocks. I'm asking if it is theoretically always possible to end up with transactions that do exactly what is needed and at the same time can never deadlock with other transactions in the same application, or if deadlocks are just unavoidable in certain cases.įirst: It is a terrible idea (a "loop-cowboy" idea) to retry a transaction on a loop because it deadlocked. Or are deadlocks completely unavoidable in certain cases?Įdit: I'm not searching for a solution. ![]() Is it even possible to completely avoid deadlocks? To write all transactions in a manner that accomplishes exactly what is needed by the application, while never deadlocking in the process. Which, I guess, is a solution, I'm just not sure how good it is.īut I also often found topics on "how to minimize deadlocks" instead of "how to prevent deadlocks". Some more usefull, some less usefull, some plainly wrong.Īmongst other things I have seen people say to just: Wrap the transaction in a loop and keep repeating until it succeeds. And I guess a lot of it is vague because they are a complex topic and preventing them is dependent on each specific case.Īs I'm trying to figure things out I have found lots of ideas and opinions and solutions to deal with them. I'm trying to understand deadlocks and tried reading on the topic. ![]()
0 Comments
Leave a Reply. |