[jboss-jira] [JBoss JIRA] Updated: (JBRULES-2114) Drools hangs with deadlock after it has initialized a rule (in multithreaded environment)

Mark Proctor (JIRA) jira-events at lists.jboss.org
Thu Jul 22 15:39:40 EDT 2010


     [ https://jira.jboss.org/browse/JBRULES-2114?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Proctor updated JBRULES-2114:
----------------------------------

    Fix Version/s: 5.1.0
                       (was: 5.1.0.CR1)


I'm pretty sure this JIRA i sout of date now and these problems have already been fixed.

> Drools hangs with deadlock after it has initialized a rule (in multithreaded environment)
> -----------------------------------------------------------------------------------------
>
>                 Key: JBRULES-2114
>                 URL: https://jira.jboss.org/browse/JBRULES-2114
>             Project: Drools
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: drools-core
>    Affects Versions: 4.0.6
>            Reporter: Andrey Nechaev
>            Assignee: Edson Tirelli
>            Priority: Critical
>             Fix For: 5.1.0
>
>         Attachments: patch-AbstractRuleBase
>
>
> Here is a scenario when drools core hangs with a deadlock:
> Suppose we heve a rule throwing an exception in the RHS. 
> So, if:
> 1. Thread A updates the Rule Base with the rule 
> 2. The rule fires (current thread is Thread A)
> 3. Rule's RHS throws an exception (still having Thread A as current)
> 4. Thread B tries to update the Rule Base or the Working Memory (for example, the Thread B inserts a fact)
> in such a case the Thread B falls into infinite wait() loop.
> Here is the test case showing such a behavior:
> package com.test;
> import java.io.StringReader;
> import org.drools.RuleBase;
> import org.drools.RuleBaseFactory;
> import org.drools.WorkingMemory;
> import org.drools.compiler.PackageBuilder;
> public class DroolsTest2 {
> 	private final static String rule = "" + 
> 	"package test\n" +
> 	"import com.test.DroolsTest2;\n" +
> 	"rule test\n" +
> 		"\twhen\n" +
> 		"\tthen\n" +
> 			"\t\tDroolsTest2.fail();" +
> 	"end";
> 	
> 	private static Object sem = new Object();
> 	private static boolean seed = false;
> 	
> 	public static void main(String[] args) throws Exception {
> 		final RuleBase rb = RuleBaseFactory.newRuleBase();
> 		final WorkingMemory wm = rb.newStatefulSession();
> 		new Thread(new Runnable() {
> 			@Override
> 			public void run() {
> 				seed = false;
> 				PackageBuilder bld = new PackageBuilder();
> 				try {
> 					bld.addPackageFromDrl(new StringReader(rule));				
> 					rb.addPackage(bld.getPackage());
> 				} catch(Exception e) {					
> 				} finally {
> 					synchronized (sem) {
> 						seed = true;
> 						sem.notify();
> 					}
> 				}
> 			}
> 		}).start();
> 		Thread ins = new Thread(new Runnable() {
> 			@Override
> 			public void run() {
> 				while(!seed) {
> 					synchronized (sem) {
> 						try {
> 							sem.wait();
> 						} catch (InterruptedException e) {}
> 					}
> 				}
> 				wm.insert(new Object());
> 			}
> 		});
> 		ins.start();
> 		ins.join();
> 	}
> 	
> 	public static void fail() {
> 		throw new IllegalStateException("fail!");
> 	}
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list