Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-3108

problems with concurrent process executions, constraints, and multiple sessions

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 5.1.1.FINAL, 5.2.0.Final
    • Fix Version/s: None
    • Component/s: drools-core (flow)
    • Labels:
      None
    • Steps to Reproduce:
      Hide
      • It is needed that drools flow is configured to use JPA.
      • Define a simple process with a wait state and an only constraint that waits for a fact to be inserted. In our case the fact and the process are related through a shared id, but this is not necessary in order to reproduce the problem in different
      • Start two different stateful sessions.
      • Start an instance of the process for every stateful session.
      • Insert the fact in only one stateful session.
      • This will continue the execution of both processes, which can be checked in the database.
      • Alternatively, the check can be done with an additional script node after the wait state.

      This is a more simple situation as that described in the original url post (http://comments.gmane.org/gmane.comp.java.drools.user/26332).

      Show
      It is needed that drools flow is configured to use JPA. Define a simple process with a wait state and an only constraint that waits for a fact to be inserted. In our case the fact and the process are related through a shared id, but this is not necessary in order to reproduce the problem in different Start two different stateful sessions. Start an instance of the process for every stateful session. Insert the fact in only one stateful session. This will continue the execution of both processes, which can be checked in the database. Alternatively, the check can be done with an additional script node after the wait state. This is a more simple situation as that described in the original url post ( http://comments.gmane.org/gmane.comp.java.drools.user/26332 ).
    • Workaround Description:
      Hide

      No workaround. We needed to apply our solution temporally modifying drools distribution.

      Show
      No workaround. We needed to apply our solution temporally modifying drools distribution.
    • Estimated Difficulty:
      Low

      Description

      The context is as follows:
      1. We have drools flow configured with JPA and Hibernate, accessing an Oracle / HSQLDB database (depending on the environment).
      2. We do have several concurrent stateful sessions in which different instances of the same kind of processes are running. These stateful sessions are persisted in the same database schema.
      3. We do use wait states (also reproduced with rule nodes) that have constraints that wait for a fact to be inserted into the stateful session.
      4. Whenever the fact that makes the constraint to satisfy is inserted for one process in a given stateful session; if there are other processes waiting in that wait state/constraint (in other different stateful sessions), the stateful session tries also to continue those process executions, even when they are not part of it.

      A solution has been implemented temporally over drools source code (in order to get our context working): the solution is briefly described in the forum url below. For completeness a summary is included here:

      • Adding a new attribute to org.drools.persistence.processinstance.ProcessInstanceInfo POJO identifying the stateful session to which the process instance corresponds (and the corresponding DB column).
      • modifying the ProcessInstancesWaitingForEvent query (in orm.xml) in order to take into account the session id as a (new) second parameter.
      • modify the class org.drools.persistence.processinstance.JPASignalManager in order to execute the query with both parameters.
      • as a quick way to have the session id, we have a threadlocal.

        Attachments

          Activity

            People

            Assignee:
            KrisVerlaenen Kris Verlaenen
            Reporter:
            jordi_alvarez Jordi Alvarez (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: