Bug #70
Using a database-session in multiple threads can deadlock the server
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
fixed
Description
We have a shutdown handler on the client that closes open sessions;
<br/>
however, this shutdown handler is run is separate thread of its own.
<br/>
So an abort of the client while it's doing a db operation can generate
<br/>
the following sequence of events which leads to a deadlock:
<br/>
<br/>
{noformat}
<br/>
Thread-1 Thread-2
<br/>
set autocommit off
<br/>
...
<br/>
insert ... close()
<br/>
{noformat}
<br/>
<br/>
(i.e. the insert and the close happen almost simultaneously). The
<br/>
resulting stack traces are roughly:
<br/>
<br/>
{noformat}
<br/>
Thread-1:
<br/>
<br/>
DatabaseSession.insert()
<br/>
DatabaseSession.execute()
<br/>
MulgaraTransaxction.execute()
<br/>
MulgaraTransaction.deactivate() <---- monitor held
<br/>
MulgaraTransaction.commitTransation()
<br/>
MulgaraTransactionManager.transacactionComplete()
<br/>
MulgaraTransactionManager.acquireMutex() <--- blocked
<br/>
<br/>
Thread-2:
<br/>
<br/>
DatabaseSession.close()
<br/>
MulgaraTransactionManager.rollbackCurrentTransactions()
<br/>
MulgaraTransactionManager.acquireMutex() <--- mutex held
<br/>
MulgaraTransaction.execute()
<br/>
MulgaraTransaction.activate() <--- blocked
<br/>
{noformat}
<br/>
<br/>
Updated by Andrae Muys - about 16 years ago
Should be resolved in branches/mgr-70.
<br/>
<br/>
Due to the patch affecting the transaction logic will wait a week for review prior to merging into trunk and closing this bug.
Updated by Andrae Muys - about 16 years ago
Merged to trunk in revision <a href="http://mulgara.org/trac/changeset/464">464</a>.