The Javadocs state that upgrading from a readLock to a writeLock is not
possible, and I've been reading other material that states that this is because
that operation is deadlock prone. The function is pretty simple, in that it
doesn't do anything inside the read lock after it's acquired the write lock. I
suggest that we de-couple the read and write lock scopes as such....
private static SimpleDirectedGraph<String, Relationship> getGraph(String
contextId) {
ReadWriteLock hierLock = HierUtil.getLock(contextId, HierUtil.Type.ROLE);
String key = getKey(contextId);
SimpleDirectedGraph<String, Relationship> graph = null;
hierLock.readLock().lock();
try {
graph = (SimpleDirectedGraph<String, Relationship>) roleCache.get(key);
if (graph != null) {
return graph;
}
} finally {
hierLock.readLock().unlock();
}
hierLock.writeLock().lock();
try {
graph = (SimpleDirectedGraph<String, Relationship>) roleCache.get(key);
if (graph != null) {
return graph;
}
graph = loadGraph(contextId);
return graph;
} finally {
hierLock.writeLock().unlock();
}
}
--
Christopher Harm
Penn State University
221 Technology Support Building
300 Science Park Road
State College, PA 16803
814-863-3366
https://keybase.io/christopherharm
----- Original Message -----
From: "Shawn McKinney" <[email protected]>
To: "Fortress Mailing List" <[email protected]>
Sent: Tuesday, March 8, 2016 8:06:27 AM
Subject: Re: LDAP Connection Management
> On Mar 7, 2016, at 8:45 AM, Emmanuel Lécharny <[email protected]> wrote:
>
> Le 07/03/16 14:58, Chris Pike a écrit :
>> So loadGraph doesn't build a new SimpleDirectedGraph? Can you point me to
>> where it is reusing an existing object?
>
> Ok, let's go back to the original issue :-)
>
> https://issues.apache.org/jira/browse/FC-38?jql=project%20%3D%20FC
>
>
> May be, back then, we just totaly fucked up when we replaced the
> synchronized block by this crazy (and buggy) ReantrantRWLock.
>
We should all agree that the code block building the graph needs to be guarded
to prevent two threads in there at once. Anything else would be sloppy and
asking for trouble. So, let’s start with the options.
1. synchronized block
2. reentrant rwlocks
1 & 2 have been tried before. I actually don’t recall what the problem with #1
was leading to switch to 2, which we now know is causes deadlocks in Chris’
servers, and I am pretty sure can be reproduced inside fortress checkaccess
jmeter load tests. (meaning it could be repaired if we wanted to)
what are our other options?
Shawn