Bug 851234

Summary: Concurrency issue: Invalid bytecode generated by KnowledgeBuilder.add()
Product: [JBoss] JBoss Enterprise SOA Platform 5 Reporter: Adam Kovari <akovari>
Component: JBoss RulesAssignee: Nobody <nobody>
Status: NEW --- QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: 5.3.0 GACC: alazarot, nobody, rwagner, soa-p-jira
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 852817 (view as bug list) Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 852817    

Description Adam Kovari 2012-08-23 14:38:22 UTC
Description of problem:
Since Drools 5.3.0.CR1 concurrent creation of different knowledgebases from filesystem DRL rule definition leads to illegal bytecode.
Reproduceable with Janino and eclipse compiler.
I have a maven based test project which executes the unit tests in parallel, this is the result:
runFirst(de.trion.drools53.TwoTest): -1
  runFirst(de.trion.drools53.FourTest): (class: de/trion/drools53/Rule_When_a_user_is_young__print_his_name_DefaultConsequenceInvoker, method: equals signature: (Ljava/lang/Object;)Z) Expecting to find integer on stack
  runSecond(de.trion.drools53.FourTest): (class: de/trion/drools53/Rule_When_a_user_is_young__print_his_name_DefaultConsequenceInvoker, method: equals signature: (Ljava/lang/Object;)Z) Expecting to find integer on stack
  runFirst(de.trion.drools53.OneTest): (class: de/trion/drools53/Rule_When_a_user_is_young__print_his_name_DefaultConsequenceInvoker, method: equals signature: (Ljava/lang/Object;)Z) Expecting to find integer on stack
  runFirst(de.trion.drools53.ThreeTest): (class: de/trion/drools53/Rule_When_a_user_is_young__print_his_name_DefaultConsequenceInvoker, method: equals signature: (Ljava/lang/Object;)Z) Incompatible object argument for function call
  runSecond(de.trion.drools53.ThreeTest): (class: de/trion/drools53/Rule_When_there_is_god__the_light_always_shines_DefaultConsequenceInvoker, method: equals signature: (Ljava/lang/Object;)Z) Unable to pop operand off an empty stack
Workaround: synchronize access
Not affected: Drools 5.3.0.Beta


Version-Release number of selected component (if applicable):
JBoss SOA-P 5.3.0

How reproducible:
https://issues.jboss.org/browse/JBRULES-3283 contains testing project and description

Comment 1 Rick Wagner 2012-11-14 14:31:06 UTC
This BZ will be resolved when we include Drools newer than 5.4 (per JBRULES-3283).

Comment 2 Shay Matasaro 2013-03-18 20:09:14 UTC
Customer has asked for a patch on 5.3 for this item, here is their issue description:

The other issue, JBRULES-3283, is actually more important. We're loading KnowledgeBuilders and KnowledgeBases on demand in various 'rule engine' components in the system (to minimize the memory footprint, '.drl' files which are not required/requested are not loaded). These engines can be accessed in parallel. Furthermore, we have one engine in which we load 71 ".drl" files in parallel into different KnowlegdeBuilders to speed up initialization. Due to JBRULES-3283 we manually need to synchronize every 'KnowledgeBuilder.add()' call using a common monitor, even though we're using different KnowlegdeBuilders. This 'workaround' is quite error-prone and when one forgets to apply it, can lead to non-deterministic problems in our rule engines.

Comment 3 Julian Coleman 2013-03-18 20:38:22 UTC
JBRULES-3283 was fixed in the version of Drools (5.3.1.BRMS-P01) released with SOA-P 5.3.1.GA.  Note, that JBRULES-3421 is not fixed in Drools 5.3.x.

Possible solutions to fix JBRULES-3283:
  upgrade to SOA-P 5.3.1.GA
  test Drools and jBPM jars from SOA-P 5.3.1 as patch to SOA-P 5.3.0.

Possible solution to fix JBRULES-3421:
  backport fix to Drools 5.3.x and include in BRMS-P 5.3.1 roll-up #1 (and SOA-P-5.3.1 roll-up #1)  [note, that inclusion in BRMS-P 5.3.1 needs to be decided very quickly]

Comment 5 Alessandro Lazarotti 2013-03-19 14:22:05 UTC
Julian, actually the "full" fix for JBRULES-3283 will be just in BRMS 5.3.1 Roll Up #1 - right? It is about our last comments on BUG 873846 - so if BRMS customer needs a fix about this, it will be there on Roll Up #1.