4 Replies Latest reply on Feb 9, 2017 8:54 AM by Dino Antonelli

    Thread lock on getKieSession()

    Dino Antonelli Newbie

      Hi,

      I need some support with JBPM 6. I'm using the 6.2.0.Final version in a multi-threaded environment. I exposed some JBPM process services as rest services. I configured the runtime environment to be PER_PROCESS_INSTANCE. I have a problem when I try to retrieve the kie session; sometimes (it happens a couple of time in a day with nearly 1000 users working...), when the application executes the following code:

       

      RuntimeEngine runtimeEngine = this.runtimeManager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId));
      KieSession ksession = runtimeEngine.getKieSession();

       

      there's a lock that blocks the execution; below a stacktrace of the thread that remains locked:

       

      service(HttpServletRequest, HttpServletResponse)

      doPost(HttpServletRequest, HttpServletResponse)

      processRequest(HttpServletRequest, HttpServletResponse)

      doService(HttpServletRequest, HttpServletResponse)

      doDispatch(HttpServletRequest, HttpServletResponse)

      handle(HttpServletRequest, HttpServletResponse, Object)

      handleInternal(HttpServletRequest, HttpServletResponse, HandlerMethod)

      invokeHandleMethod(HttpServletRequest, HttpServletResponse, HandlerMethod)

      invokeAndHandle(ServletWebRequest, ModelAndViewContainer, Object[])

      invokeForRequest(NativeWebRequest, ModelAndViewContainer, Object[])

      doInvoke(Object[])

      invoke(Object, Object[])

      invoke(Object, Object[])

      invoke(Object, Object[])

      completeTask(long, long, DocumentUpdate)

      completeTaskByProcess(String, long, long, HashMap)

      getKSession(Long)

      getKieSession()

      initKieSession(Context, InternalRuntimeManager, RuntimeEngine)

      findKieSessionById(Long)

      getConfiguration()

      newKieSessionConfiguration(Properties, ClassLoader)

      <init>(Properties, ClassLoader)

      init(Properties, ClassLoader[])

      <init>(String, ClassLoader)

      <init>(String, ClassLoader, boolean)

      getResources(String, ClassLoader)

      getResources(String)

      getResources(String)

      getResources(String)

      findResources(String, boolean)

      getResources(String)

      loadResourceLocal(String)

      loadResourceLocal(String)

      getResource(String)

      doPrivileged(PrivilegedAction)

      run()

      run()

      toURL()

      getVirtualURL(VirtualFile)

      getVirtualURI(VirtualFile)

      getPathName(boolean)

      isDirectory()

      isDirectory(VirtualFile, VirtualFile)

      doPrivileged(PrivilegedAction)

      loadStatefulKnowledgeSession(Long, KieBase, KieSessionConfiguration, Environment)

      loadKieSession(Long, KieBase, KieSessionConfiguration, Environment)

      loadKieSession(Long, KieBase, KieSessionConfiguration, Environment)

      buildCommandService(Long, KieBase, KieSessionConfiguration, Environment)

      newInstance(Object[])

      newInstance(Object[])

      newInstance(Object[])

      <init>(Long, KieBase, KieSessionConfiguration, Environment)

      initExistingKnowledgeSession(Long, KieBase, KieSessionConfiguration, PersistenceContext)

      loadSnapshot(byte[], KieSession)

      unmarshall(InputStream, KieSessionConfiguration, Environment)

      unmarshall(InputStream, KieSessionConfiguration, Environment)

      readSession(MarshallerReaderContext, int, Environment, SessionConfiguration)

      createAndInitializeSession(MarshallerReaderContext, int, Environment, SessionConfiguration, ProtobufMessages$KnowledgeSession)

      createWorkingMemory(long, InternalKnowledgeBase, FactHandleFactory, InternalFactHandle, long, SessionConfiguration, InternalAgenda, Environment)

      <init>(long, InternalKnowledgeBase, FactHandleFactory, InternalFactHandle, long, SessionConfiguration, InternalAgenda, Environment)

      <init>(long, InternalKnowledgeBase, FactHandleFactory, boolean, long, SessionConfiguration, Environment, RuleRuntimeEventSupport, AgendaEventSupport, RuleEventListenerSupport, InternalAgenda)

      createProcessRuntime()

      newProcessRuntime(StatefulKnowledgeSessionImpl)

      newProcessRuntime(InternalWorkingMemory)

      newProcessRuntime(InternalWorkingMemory)

      <init>(InternalWorkingMemory)

      initProcessEventListeners()

      addEventListener(KieBaseEventListener)

      contains(Object)

      containsKey(Object)

      getEntry(Object)

       

      It seems that the thread remain in wait in the following sychronized method of the AbstractEventSupport object in the contains call:

       

          public final synchronized void addEventListener(final E listener) {

              if (!this.listeners.contains(listener)) {

                  this.listeners.add(listener);

              }

          }

       

       

      Does anyone know anything about this issue???

       

      Thanks

      Dino