In databases, when multiple processes alter the same table or row, each can lock a table or row. When they need to alter or lock the same resource to complete, that can cause deadlocks, or irreconcilable contention between the processes, causing one of them to be stopped by the system.
10
votes
3answers
1k views
Mysql transaction waiting for lock which is already granted .. This is causing deadlock
If following situation a bug in mysql?.
Mysql Version: mysql.x86_64 5.0.77-4.el5_4.1
Kernel: Linux box2 2.6.18-128.el5 #1 SMP Wed Jan 21 10:41:14 EST 2009 x86_64 x86_64 x86_64 GNU/Linux
...
8
votes
2answers
269 views
Can two “SELECT FOR UPDATE” statements on the same table cause a deadlock?
Suppose that two simultaneous transactions execute the following queries on a Postgresql DB:
Transaction A:
SELECT * FROM mytable WHERE id IN (1, 2, 3, 4) FOR UPDATE
Transaction B:
SELECT * FROM ...
7
votes
4answers
6k views
Deadlock error in INSERT statement
We've got a web-based application. There are time-bound database operations (INSERTs and UPDATEs) in the application which take more time to complete, hence this particular flow has been changed into ...
6
votes
4answers
12k views
Working around MySQL error “Deadlock found when trying to get lock; try restarting transaction”
I have a MySQL table with about 5,000,000 rows that are being constantly updated in small ways by parallel Perl processes connecting via DBI. The table has about 10 columns and several indexes.
One ...
6
votes
2answers
554 views
Trying to understand MySQL deadlock on InnoDB table
I'm trying to understand a deadlock found by MySQL during concurrent clients processing on the same tables. This is the interesting part of the "SHOW InnoDB STATUS" command:
------------------------
...
5
votes
1answer
4k views
How to do a safe “SELECT FOR UPDATE” with a WHERE condition over multiple tables on a DB2?
Problem
On a DB2 (version 9.5) the SQL statement
SELECT o.Id FROM Table1 o, Table2 x WHERE [...] FOR UPDATE WITH RR
gives me the error message SQLSTATE=42829 (The FOR UPDATE clause is not allowed ...
5
votes
5answers
542 views
Deadlock in SQL Server 2005! Two real-time bulk upserts are fighting. WHY?
Here's the scenario:
I've got a table called MarketDataCurrent (MDC) that has live updating stock prices.
I've got one process called 'LiveFeed' which reads prices streaming from the wire, ...
5
votes
1answer
762 views
How is Hibernate deciding order of update/insert/delete
Let's first forget about Hibernate. Assume that I have two tables, A & B. Two transactions are updating same records in these two tables, but txn 1 update B and then A, while txn 2 update A then ...
5
votes
4answers
4k views
Handle NHibernate Transaction Errors
Our application (which uses NHibernate and ASP.NET MVC), when put under stress tests throws a lot of NHibernate transaction errors. The major types are:
Transaction not connected, or was ...
4
votes
3answers
2k views
I have data about deadlocks, but I can't understand why they occur
I am receiving a lot of deadlocks in my big web application.
http://stackoverflow.com/questions/2941233/how-to-automatically-re-run-deadlocked-transaction-asp-net-mvc-sql-server
Here I wanted to ...
4
votes
5answers
2k views
Multithreading - Avoiding and dealing with database deadlocks
I am looking for a good strategy of dealing with database deadlocks from within a Java 6 application; several parallel threads could, potentially, write into the same table at the same time. The ...
4
votes
2answers
904 views
How do I identify a deadlock in SQL Azure?
I have a Windows Azure role that consists of two instances. Once in a while a transaction will fail with an SqlException with the following text
Transaction (Process ID N) was deadlocked on lock ...
4
votes
4answers
6k views
Sybase ASE: “Your server command encountered a deadlock situation”
When running a stored procedure (from a .NET application) that does an INSERT and an UPDATE, I sometimes (but not that often, really) and randomly get this error:
ERROR [40001] [DataDirect][ODBC ...
4
votes
2answers
380 views
Implementing retry logic for deadlock exceptions
I've implemented a generic repository and was wondering if there is a smart way to implement a retry logic in case of a deadlock exception?
The approach should be the same for all repository methods. ...
4
votes
1answer
488 views
What are locking, deadlocking issues in financial operations?
Subquestioning SQL - when should you use “with (nolock)”
In one local financial institution I was rebuked by their programmers for expressing them my opinion that (their programmers' obsession with) ...