This only happens very occasionally and we have not found a way to reproduce the error. Nether occasion has been during any heavy load though both occasions have been at the same point in the BPMN where two parallel flows are executing a task each before entering an inclusive gateway. What we see is this error on the first task:
### Error querying database. Cause: java.lang.NullPointerException ### Cause: java.lang.NullPointerException org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.lang.NullPointerException ### Cause: java.lang.NullPointerException at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23) ~[mybatis-3.2.5.jar:3.2.5] at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:107) ~[mybatis-3.2.5.jar:3.2.5] at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98) ~[mybatis-3.2.5.jar:3.2.5] at org.activiti.engine.impl.db.DbSqlSession.selectListWithRawParameterWithoutFilter(DbSqlSession.java:426) ~[activiti-engine-5.16.1.jar:5.16.1] at org.activiti.engine.impl.persistence.entity.TaskEntityManager.findTasksAndVariablesByQueryCriteria(TaskEntityManager.java:139) ~[activiti-engine-5.16.1.jar:5.16.1] at org.activiti.engine.impl.TaskQueryImpl.executeList(TaskQueryImpl.java:930) ~[activiti-engine-5.16.1.jar:5.16.1] at org.activiti.engine.impl.AbstractQuery.executeSingleResult(AbstractQuery.java:158) ~[activiti-engine-5.16.1.jar:5.16.1] at org.activiti.engine.impl.AbstractQuery.execute(AbstractQuery.java:141) ~[activiti-engine-5.16.1.jar:5.16.1] at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24) ~[activiti-engine-5.16.1.jar:5.16.1] at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57) ~[activiti-engine-5.16.1.jar:5.16.1] at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47) ~[activiti-spring-5.16.1.jar:5.16.1] at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133) ~[spring-tx-4.1.3.RELEASE.jar:4.1.3.RELEASE] at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45) ~[activiti-spring-5.16.1.jar:5.16.1] at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31) ~[activiti-engine-5.16.1.jar:5.16.1] at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40) ~[activiti-engine-5.16.1.jar:5.16.1] at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35) ~[activiti-engine-5.16.1.jar:5.16.1] at org.activiti.engine.impl.AbstractQuery.singleResult(AbstractQuery.java:104) ~[activiti-engine-5.16.1.jar:5.16.1]
and 1/10th of a second later the other task correctly makes this query call and continues on while the first leg is left in as stalled state and never reaches the gateway.
We have looked at past forum posts and note that it seems very similar to an old bug fixed in version 5.13 (while we are on a much later version 5.17) :
That particular bug raised was on a createProcessInstanceQuery() while we are using a taskQuery. Is it possible the bug was fixed only for processInstance queries? (The old link to the fix is no longer available).
Can you shed any light on what this issue might be and why it could be happening so infrequently?
For now it seems that our only workaround is a crude one - wrapping this call in a try/catch, waiting and then retrying a specific number of times before failing