Uploaded image for project: 'jBPM'
  1. jBPM
  2. JBPM-10072

EJBTimerScheduler.getTimerByName inefficient with large number of timers and 'org.jbpm.ejb.timer.local.cache=false'

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Done
    • Icon: Major Major
    • 7.70.0.Final
    • None
    • None

      With a large number of timers (expiration date > jboss.ejb.timer.database.clearTimerInfoCacheBeyond value), the loop in EJBTimerScheduler.getTimerByName() is inefficient and leads to bad performance due to a large number of DB requests:

      "default task-25" #293 prio=5 os_prio=0 cpu=616.07ms elapsed=9.33s tid=0x000055f3fecd5000 nid=0x1be3e3 runnable  [0x00007f079bda7000]
         java.lang.Thread.State: RUNNABLE
      	at java.net.SocketInputStream.socketRead0(java.base@11.0.14.1/Native Method)
      	at java.net.SocketInputStream.socketRead(java.base@11.0.14.1/SocketInputStream.java:115)
      	at java.net.SocketInputStream.read(java.base@11.0.14.1/SocketInputStream.java:168)
      	at java.net.SocketInputStream.read(java.base@11.0.14.1/SocketInputStream.java:140)
      	at org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:140)
      	at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:109)
      	at org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:67)
      	at org.postgresql.core.PGStream.receiveChar(PGStream.java:293)
      	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1947)
      	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:306)
      	- locked <0x00000007656a6618> (a org.postgresql.core.v3.QueryExecutorImpl)
      	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
      	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
      	at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:307)
      	at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:293)
      	at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:270)
      	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:266)
      	at org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker.isValidConnection(PostgreSQLValidConnectionChecker.java:61)
      	at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnectionFactory.isValidConnection(BaseWrapperManagedConnectionFactory.java:1372)
      	at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnectionFactory.getInvalidConnections(BaseWrapperManagedConnectionFactory.java:1179)
      	at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.getConnection(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:382)
      	at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getSimpleConnection(AbstractPool.java:640)
      	at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:605)
      	at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:624)
      	at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:440)
      	at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:789)
      	at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:151)
      	at org.jboss.as.connector.subsystems.datasources.WildFlyDataSource.getConnection(WildFlyDataSource.java:64)
      	at org.jboss.as.ejb3.timerservice.persistence.database.DatabaseTimerPersistence.getPersistedTimerInfo(DatabaseTimerPersistence.java:884)
      	at org.jboss.as.ejb3.timerservice.TimerServiceImpl.getPersistedTimerInfo(TimerServiceImpl.java:580)
      	at org.jboss.as.ejb3.timerservice.TimerImpl.getTimerInfo(TimerImpl.java:230)
      	at org.jboss.as.ejb3.timerservice.TimerImpl.getInfo(TimerImpl.java:216)
      	at org.jbpm.services.ejb.timer.EJBTimerScheduler.getTimerByName(EJBTimerScheduler.java:354)  // <-- LOOP
      ...
      	at org.jbpm.services.ejb.timer.EJBTimerScheduler$$$view2.getTimerByName(Unknown Source)
      	at org.jbpm.services.ejb.timer.EjbSchedulerService.scheduleJob(EjbSchedulerService.java:69)
      	at org.jbpm.process.core.timer.impl.GlobalTimerService.registerJobHandle(GlobalTimerService.java:163)
      	at org.jbpm.process.core.timer.impl.GlobalTimerService.scheduleJob(GlobalTimerService.java:117)
      	at org.jbpm.process.core.timer.impl.RegisteredTimerServiceDelegate.scheduleJob(RegisteredTimerServiceDelegate.java:68)
      	at org.jbpm.process.instance.timer.TimerManager$ProcessTimerInputMarshaller.deserialize(TimerManager.java:271)
      	at org.drools.serialization.protobuf.ProtobufInputMarshaller.readTimer(ProtobufInputMarshaller.java:729)
      	at org.drools.serialization.protobuf.ProtobufInputMarshaller.readSession(ProtobufInputMarshaller.java:290)
      	at org.drools.serialization.protobuf.ProtobufInputMarshaller.readSession(ProtobufInputMarshaller.java:165)
      	at org.drools.serialization.protobuf.ProtobufMarshaller.unmarshallWithMessage(ProtobufMarshaller.java:144)
      	at org.drools.serialization.protobuf.ProtobufMarshaller.unmarshall(ProtobufMarshaller.java:95)
      	at org.drools.serialization.protobuf.ProtobufMarshaller.unmarshall(ProtobufMarshaller.java:53)
      	at org.drools.persistence.api.SessionMarshallingHelper.loadSnapshot(SessionMarshallingHelper.java:99)
      	at org.drools.persistence.PersistableRunner.initExistingKnowledgeSession(PersistableRunner.java:254)
      	at org.drools.persistence.PersistableRunner. (PersistableRunner.java:192)
      	at jdk.internal.reflect.GeneratedConstructorAccessor227.newInstance(Unknown Source)
      	at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(java.base@11.0.14.1/DelegatingConstructorAccessorImpl.java:45)
      	at java.lang.reflect.Constructor.newInstance(java.base@11.0.14.1/Constructor.java:490)
      	at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommandService(KnowledgeStoreServiceImpl.java:122)
      	at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.loadKieSession(KnowledgeStoreServiceImpl.java:104)
      	at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.loadKieSession(KnowledgeStoreServiceImpl.java:36)
      	at org.kie.internal.persistence.jpa.JPAKnowledgeService.loadStatefulKnowledgeSession(JPAKnowledgeService.java:144)
      	at org.jbpm.runtime.manager.impl.factory.JPASessionFactory.findKieSessionById(JPASessionFactory.java:61)
      	at org.jbpm.runtime.manager.impl.PerProcessInstanceRuntimeManager$PerProcessInstanceInitializer.initKieSession(PerProcessInstanceRuntimeManager.java:590)
      	at org.jbpm.runtime.manager.impl.RuntimeEngineImpl.internalGetKieSession(RuntimeEngineImpl.java:163)
      	at org.jbpm.services.task.wih.ExternalTaskEventListener.afterTaskCompletedEvent(ExternalTaskEventListener.java:109)
      ...
      	at org.jbpm.services.task.commands.TaskCommandExecutorImpl.execute(TaskCommandExecutorImpl.java:49)
      	at org.jbpm.services.task.impl.command.CommandBasedTaskService.complete(CommandBasedTaskService.java:176)
      	at org.jbpm.kie.services.impl.UserTaskServiceImpl.complete(UserTaskServiceImpl.java:230)
      	at org.kie.server.services.jbpm.UserTaskServiceBase.complete(UserTaskServiceBase.java:112)
      	at org.kie.server.remote.rest.jbpm.UserTaskResource.complete(UserTaskResource.java:258)
      

              rhn-support-egonzale Enrique Gonzalez Martinez (Inactive)
              rhn-support-egonzale Enrique Gonzalez Martinez (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: