[jboss-jira] [JBoss JIRA] Commented: (JBRULES-2135) Deadlock occurs in Multithreaded Environment NamedEntryPoint lock and AbstractWorkingMemory actionQueue sync block.
Jonathon Leibundguth (JIRA)
jira-events at lists.jboss.org
Mon Jun 22 09:55:57 EDT 2009
[ https://jira.jboss.org/jira/browse/JBRULES-2135?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12473255#action_12473255 ]
Jonathon Leibundguth commented on JBRULES-2135:
-----------------------------------------------
I believe something like this replaced method for AbstractWorkingMemory may resolve the issue, but I am not fully versed in the Drools Core code (pls don't kill me) - also this was a quick fix to unblock our project, there may be a more elegant impl., but point is to either move the execute() action outside of the sync block or find another avenue to resolve deadlock between actionQueue locking and NamedEntryPoint Reentrant lock:
public void executeQueuedActions() {
// fill this so that execute is called outside of the sync block to avoid deadlock
Queue<WorkingMemoryAction> execQueue = new LinkedList<WorkingMemoryAction>();
synchronized ( this.actionQueue ) {
if ( !this.actionQueue.isEmpty() && !evaluatingActionQueue ) {
evaluatingActionQueue = true;
WorkingMemoryAction action = null;
while ( (action = actionQueue.poll()) != null ) {
execQueue.add(action);
}
evaluatingActionQueue = false;
}
}
WorkingMemoryAction execAction = null;
while ( (execAction = execQueue.poll()) != null ) {
try {
execAction.execute( this );
} catch ( Exception e ) {
if( e instanceof RuntimeDroolsException ) {
// rethrow the exception
throw ((RuntimeDroolsException)e);
} else {
System.err.println("************************************************");
System.err.println("Exception caught while executing action: "+execAction.toString());
e.printStackTrace();
}
}
}
}
> Deadlock occurs in Multithreaded Environment NamedEntryPoint lock and AbstractWorkingMemory actionQueue sync block.
> -------------------------------------------------------------------------------------------------------------------
>
> Key: JBRULES-2135
> URL: https://jira.jboss.org/jira/browse/JBRULES-2135
> Project: JBoss Drools
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: drools-core (fusion)
> Affects Versions: 5.0.1.FINAL
> Environment: java version "1.6.0_0"
> OpenJDK Runtime Environment (IcedTea6 1.4.1) (6b14-1.4.1-0ubuntu7)
> OpenJDK Client VM (build 14.0-b08, mixed mode, sharing)
> Reporter: Jonathon Leibundguth
> Assignee: Mark Proctor
> Priority: Critical
>
> While running drools using fireUntilHalt in multithreaded environment, the following situation results in deadlock:
> Thread A (Drools' Thread): AbstractWorkingMemory method executeQueuedActions() locks actionQueue:
> synchronized ( this.actionQueue )
> Calls action.execute( this ) for each item in queue, in this case WorkingMemoryReteExpireAction to expire an event object. The WorkingMemoryReteExpireAction tries to obtain the lock in NamedEntryPoint during call to retract().
> Thread B (User's Thread): attempts to execute a NamedEntryPoint insert() action simultaneously with the above. The thread obtains the NamedEntryPoint lock and blocks waiting for the lock on actionQueue.
> Deadlock:
> Thread A is blocked waiting for NamedEntryPoint lock, owned by Thread B.
> Thread B is blocked waiting for lock on actionQueue, owned by Thread A.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list