martinweiler opened a new pull request, #7309:
URL: https://github.com/apache/incubator-kie/pull/7309

   Closes: https://github.com/apache/incubator-kie/issues/7308
   
   **Problem**
   After restarting a Quarkus app that uses embedded jobs with JPA/PostgreSQL, 
overdue timers fire as expected. Some of the job-timeout transactions then fail 
at commit with:
   
   ```
   ARJUNA012125: TwoPhaseCoordinator.beforeCompletion - failed ...
   jakarta.persistence.OptimisticLockException: Unexpected row count (expected 
row count 1 but was 0)
   [update job_details set correlation_id=?, ... where id=?]
   for entity [org.kie.kogito.app.jobs.jpa.model.JobDetailsEntity with id '...']
   Caused by: org.hibernate.StaleObjectStateException
   ```
   
   The error does not appear when timers fire while the app is running.
   
   **Fix**
   `JobDetailsEntityHelper.from()` now removes `classType` from `deepCopy()` 
copies of the recipient and trigger JSON. The managed entity is no longer 
modified, so Hibernate no longer flags it dirty.
   
   **Tests**
   New `JobDetailsEntityHelperTest` in `kogito-addons-common-embedded-jobs-jpa`:
   - `testFromDoesNotMutateEntity` builds an entity with `merge()`, calls 
`from()`, and asserts the entity's recipient and trigger JSON are unchanged. 
This is the regression guard for the `UPDATE`. Hibernate flags an entity as 
dirty exactly when its JSON attributes change.
   - `testFromCanBeCalledRepeatedly` calls `from()` twice on the same entity 
and checks both results match. It guards against `from()` depending on state it 
changed on an earlier call.
   
   


-- 
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]

Reply via email to