Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-1046

Threads blocking during ReteWorkingMemory initialization of facts

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 6.4.0.Beta2
    • 6.3.0.Final
    • core engine
    • None
    • Hide

      Create a drools file with the following condition:

      rule "slowWhenCondition" 
      	when
      		eval(mySlowCondition(fact))
      	then
      		
      end
      

      Create a StatefulSession and fire all the rules from multiple threads. Observe the threads in Blocking state using JVisualVM or Stack Trace.

      Show
      Create a drools file with the following condition: rule "slowWhenCondition" when eval(mySlowCondition(fact)) then end Create a StatefulSession and fire all the rules from multiple threads. Observe the threads in Blocking state using JVisualVM or Stack Trace.
    • NEW
    • NEW

    Description

      While initializing facts for the first time the following method in ReteWorkingMemory is invoked:

          private final Integer syncLock = 42;
          public void initInitialFact() {
              if ( initialFactHandle == null ) {
                  synchronized ( syncLock ) {
                      if ( initialFactHandle == null ) {
                          // double check, inside of sync point incase some other thread beat us to it.
                          initInitialFact(kBase, null);
                      }
                  }
              }
          }
      

      Since the synchronized lock is taken on a Integer constant variable, the same object gets used across different threads. This causes the initialization of all the ReteMemoryObjects to wait in the initInitialFact() method across different threads.

      The lock should be taken on Object lock = new Object() instead

      Attachments

        Activity

          People

            mfusco@redhat.com Mario Fusco
            akshaygehi-sst Akshay Gehi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: