martinweiler opened a new pull request, #7271: URL: https://github.com/apache/incubator-kie/pull/7271
Closes https://github.com/apache/incubator-kie/issues/7269 **Problem:** In `VertxJobScheduler`, registered `JobTimeoutInterceptor`s (such as `TransactionJobTimeoutInterceptor`) wrap the job execution in a database transaction before the job is executed. However, `ProcessInstanceAtomicLockStrategy` was previously only acquired downstream within the workflow engine (`AbstractProcessInstance`). When a timer fired concurrently with another operation on the same process instance (e.g., an external REST signal or another job execution): 1. The timer thread opened a database transaction, pinning its MVCC/read snapshot. 2. The timer thread then blocked waiting for the in-memory `ProcessInstanceAtomicLockStrategy` lock held by the concurrent operation. 3. After the concurrent operation committed and released the lock, the timer thread resumed execution within its already-open transaction containing a stale read view. 4. Subsequent writes resulted in optimistic locking failures / MVCC serialization conflicts, causing transaction rollback and unnecessary job retries. In addition, `newTimeoutTask` in `VertxJobScheduler` was attempting to remove obsolete entries from `jobsScheduled` using `jobId` rather than the composite `mapKey` (`jobId + "-" + retries`). **Solution:** 1. Move `ProcessInstanceAtomicLockStrategy` to `kogito-services` so it can be shared with `jobs-common-embedded`. 2. Wrap the intercepted timeout execution in `VertxJobScheduler` with `ProcessInstanceAtomicLockStrategy.instance().executeOperation(processInstanceId, ...)` so that the process instance lock is acquired prior to starting the database transaction. 3. Propagate `mapKey` through the Vert.x timeout handler so that `TimerInfo` lookup (for `correlationId`) and map removal on cancellation work correctly. 4. Optimize `GenericRepository` event type updates to avoid redundant delete/insert cycles when event types have not changed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
