cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Huss (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAY-1782) Deadlock when performing many concurrent inserts
Date Wed, 19 Dec 2012 15:31:13 GMT

    [ https://issues.apache.org/jira/browse/CAY-1782?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13536035#comment-13536035
] 

John Huss commented on CAY-1782:
--------------------------------

You're right, it is connection exhaustion, not deadlock per se since it does not stay locked
forever.  But it is deadlock in the sense that two threads have obtained locks and are waiting
for each other - one of them just doesn't wait forever.  As I've thought about it more, there
may be a different/better fix if I understand it correctly.  But I'm not very familiar with
this code and I'm only addressing it out of necessity.  My understanding is this:

- First thread tries to save and checks out a DB connection from the pool
- First thread realizes it needs to generate a primary key and locks the pkCache
- Second thread tries to save and checks out a DB connection from the pool
- First thread tries to check out ANOTHER connection from the pool to run the sql to generate
a PK (the problem is that it should use the connection it already has).
- Second thread realizes it needs to generate a primary key and waits to lock the pkCache
- stuck
- First thread can't obtain a connection because the second thread has one and IT already
has one!

I'm not positive on that, but it's my best shot at the moment.  If that is the case, then
the problem could be avoided by allowing the pk generator code to use an exiting database
connection passed in as a parameter rather than having it obtain one itself.
                
> Deadlock when performing many concurrent inserts
> ------------------------------------------------
>
>                 Key: CAY-1782
>                 URL: https://issues.apache.org/jira/browse/CAY-1782
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 3.0, 3.1 (final), 3.2M1
>            Reporter: John Huss
>            Assignee: John Huss
>             Fix For: 3.2M1
>
>
> I've encountered a deadlock issue in production in an app performing many INSERTs.  The
deadlock was between the PK generator and the PoolManager (getting a DB connection).  It is
very bad.  I added a unit test demonstrating the problem and a fix for it.
> The fix is possibly not ideal because it requires a larger data structure for holding
the cached primary keys, but it is far better than the previous behavior.
> If this fix is acceptable this should be back-ported to 3.1 as well.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message