Possible bug detected when executing runtimeService.createExecutionQuery with piid and activityid concurrently

Hello, I have a bpm flow of orders with a “Receive Task” to which I am sending, as a test, 50 messages concurrently every second for 3 seconds and I am experiencing the following problem.

In at least 4 executions the executeResumeProcessInstanceById method fails to find the execution.

` @Override
public void executeResumeProcessInstanceById(String piid, String activityid, String sbiesXmlRsp)
throws SigresSromGenericException {
ExecutionQuery executionQuery = runtimeService.createExecutionQuery();

	Execution execution =  executionQuery
			.processInstanceId(piid)
			.activityId(activityid)
			.singleResult();
	
	if (execution == null) {
		logger.debug("###################### DEBUG #####################");
		logger.debug(">> Possible bug detected when executing runtimeService.createExecutionQuery with piid: {} and activityid: {} concurrently", piid, activityid);
		executionQuery
				.list()
				.forEach(e -> {
					logger.debug(">> ProcessInstanceId available: {}",e.getProcessInstanceId());
					});
		logger.debug("###################### DEBUG #####################");
	}
	
	Map<String, Object> varMap = new HashMap<>();
	varMap.put("internal_" + SromConstants.SBIES_RSP_XML_MSG, SpinValues.xmlValue(sbiesXmlRsp).create());
	runtimeService.signal(execution.getId(), varMap);
}`

However, and here is the strange thing, the execution is there, I have put traces that prove it to me.

2022-03-16T16:17:07,535Z [SROM.SBI.OUT.container-4] DEBUG org.srom.bpm.impl.BpmServicesImpl - ###################### DEBUG #####################
2022-03-16T16:17:07,535Z [SROM.SBI.OUT.container-4] DEBUG org.srom.bpm.impl.BpmServicesImpl - >> Possible bug detected when executing runtimeService.createExecutionQuery with piid: 864ec132-a544-11ec-bd5e-4e3070d2511f and activityid: ReceiveJmsRspFromSbiAdapt
2022-03-16T16:17:07,536Z [pool-1-thread-106] DEBUG o.i.s.srom.bpm.handlers.SendReqToSbiAdapterHandler - starting prepareCreateCustomOperReq …
2022-03-16T16:17:07,537Z [pool-1-thread-106] DEBUG o.i.s.srom.bpm.handlers.SendReqToSbiAdapterHandler - starting prepareUpdtOrdStartOperInprogress …
2022-03-16T16:17:07,533Z [SROM.SBI.OUT.container-1] DEBUG o.i.s.s.bpm.handlers.ListenerResumeProcessHandler - starting resumeProcessHandler …
2022-03-16T16:17:07,537Z [SROM.SBI.OUT.container-1] DEBUG o.i.s.s.bpm.handlers.ListenerResumeProcessHandler - Resuming process with piid: 864d1322-a544-11ec-bd5e-4e3070d2511f
2022-03-16T16:17:07,542Z [pool-1-thread-92] DEBUG o.i.s.s.b.h.ProcessResponseFromSbiAdapterHandler - starting prepareTransfSbiesToCustOper …
2022-03-16T16:17:07,544Z [SROM.SBI.OUT.container-4] DEBUG org.srom.bpm.impl.BpmServicesImpl - >> ProcessInstanceId available: 8647959a-a544-11ec-bd5e-4e3070d2511f
2022-03-16T16:17:07,544Z [SROM.SBI.OUT.container-4] DEBUG org.srom.bpm.impl.BpmServicesImpl - >> ProcessInstanceId available: 864cc5db-a544-11ec-bd5e-4e3070d2511f
2022-03-16T16:17:07,544Z [SROM.SBI.OUT.container-4] DEBUG org.srom.bpm.impl.BpmServicesImpl - >> ProcessInstanceId available: 864cebf2-a544-11ec-bd5e-4e3070d2511f
2022-03-16T16:17:07,544Z [SROM.SBI.OUT.container-4] DEBUG org.srom.bpm.impl.BpmServicesImpl - >> ProcessInstanceId available: 864d1322-a544-11ec-bd5e-4e3070d2511f
2022-03-16T16:17:07,544Z [SROM.SBI.OUT.container-4] DEBUG org.srom.bpm.impl.BpmServicesImpl - >> ProcessInstanceId available: 864daf9d-a544-11ec-bd5e-4e3070d2511f
2022-03-16T16:17:07,544Z [SROM.SBI.OUT.container-4] DEBUG org.srom.bpm.impl.BpmServicesImpl - >> ProcessInstanceId available: 864ec132-a544-11ec-bd5e-4e3070d2511f
2022-03-16T16:17:07,544Z [SROM.SBI.OUT.container-4] DEBUG org.srom.bpm.impl.BpmServicesImpl - >> ProcessInstanceId available: 8651ce99-a544-11ec-bd5e-4e3070d2511f
2022-03-16T16:17:07,544Z [SROM.SBI.OUT.container-4] DEBUG org.srom.bpm.impl.BpmServicesImpl - >> ProcessInstanceId available: 8651f5c0-a544-11ec-bd5e-4e3070d2511f
2022-03-16T16:17:07,544Z [SROM.SBI.OUT.container-4] DEBUG org.srom.bpm.impl.BpmServicesImpl - >> ProcessInstanceId available: 865466eb-a544-11ec-bd5e-4e3070d2511f
2022-03-16T16:17:07,544Z [SROM.SBI.OUT.container-4] DEBUG org.srom.bpm.impl.BpmServicesImpl - >> ProcessInstanceId available: 86559e8c-a544-11ec-bd5e-4e3070d2511f
2022-03-16T16:17:07,544Z [SROM.SBI.OUT.container-4] DEBUG org.srom.bpm.impl.BpmServicesImpl - >> ProcessInstanceId available: 864d1322-a544-11ec-bd5e-4e3070d2511f
2022-03-16T16:17:07,544Z [SROM.SBI.OUT.container-4] DEBUG org.srom.bpm.impl.BpmServicesImpl - >> ProcessInstanceId available: 864daf9d-a544-11ec-bd5e-4e3070d2511f
2022-03-16T16:17:07,544Z [SROM.SBI.OUT.container-4] DEBUG org.srom.bpm.impl.BpmServicesImpl - ###################### DEBUG #####################

I will appreciate your help or recommendations to solve this possible concurrency problem.

Greetings

my “work arround” is to retry :frowning: , and it works!