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] [Comment Edited] (CAY-1782) Deadlock when performing many concurrent inserts
Date Mon, 24 Dec 2012 21:36:12 GMT

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

John Huss edited comment on CAY-1782 at 12/24/12 9:35 PM:
----------------------------------------------------------

You're right, good ideas.  Here's that portion reimplemented:

Queue<Long> pks = pkCache.get(entity.getName());

if (pks == null) {
    // created exhausted LongPkRange
    pks = new ConcurrentLinkedQueue<Long>();
    Queue<Long> previousPks = pkCache.putIfAbsent(entity.getName(), pks);
    if (previousPks != null) {
    	pks = previousPks;
    }
}

if (pks.isEmpty()) {
	value = longPkFromDatabase(node, entity);
	for (long i = value+1; i < value + cacheSize; i++) {
            pks.add(i);
	}
} else {
     value = pks.poll();
}
                
      was (Author: johnthuss):
    You're right, good ideas.  Here's that portion reimplemented:

Queue<Long> pks = pkCache.get(entity.getName());

if (pks == null) {
    // created exhausted LongPkRange
    pks = new ConcurrentLinkedQueue<Long>();
    Queue<Long> previousPks = pkCache.putIfAbsent(entity.getName(), pks);
    if (previousPks != null) {
    	pks = previousPks;
    }
}

if (pks.isEmpty()) {
	value = longPkFromDatabase(node, entity);
	for (long i = value+1; i < value + cacheSize; i++) {
            pks.offer(i);
	}
} else {
     value = pks.poll();
}
                  
> 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