I have experienced an issue while updating an instance of a JPA server, version 6.1.0, to the latest 6.6.0.
I followed the instructions for executing a database migration (
https://hapifhir.io/hapi-fhir/docs/server_jpa/upgrading.html), and the operation completed successfully.
When I run the JPA server ver 6.6.0, it starts correctly, but it raises every minute the following exception:
2023-06-09 14:19:09.617 [hapi-fhir-jpa-scheduler-clustered-1] INFO c.uhn.fhir.log.batch_troubleshooting [JobMaintenanceServiceImpl.java:203] Maintenance pass starting.
2023-06-09 14:19:09.631 [hapi-fhir-jpa-scheduler-clustered-1] INFO o.h.e.j.b.internal.AbstractBatchImpl [AbstractBatchImpl.java:213] HHH000010: On release of batch it still contained JDBC statements
2023-06-09 14:19:09.631 [hapi-fhir-jpa-scheduler-clustered-1] ERROR o.h.e.j.batch.internal.BatchingBatch [BatchingBatch.java:139] HHH000315: Exception executing batch [org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; statement executed: update bt2_job_instance set job_cancelled=?, cmb_recs_processed=?, cmb_recs_per_sec=?, create_time=?, cur_gated_step_id=?, definition_id=?, definition_ver=?, end_time=?, error_count=?, error_msg=?, est_remaining=?, fast_tracking=?, params_json=?, params_json_lob=?, progress_pct=?, report=?, start_time=?, stat=?, tot_elapsed_millis=?, update_time=?, work_chunks_purged=? where id=? and update_time=?], SQL: update bt2_job_instance set job_cancelled=?, cmb_recs_processed=?, cmb_recs_per_sec=?, create_time=?, cur_gated_step_id=?, definition_id=?, definition_ver=?, end_time=?, error_count=?, error_msg=?, est_remaining=?, fast_tracking=?, params_json=?, params_json_lob=?, progress_pct=?, report=?, start_time=?, stat=?, tot_elapsed_millis=?, update_time=?, work_chunks_purged=? where id=? and update_time=?
2023-06-09 14:19:09.633 [hapi-fhir-jpa-scheduler-clustered-1] ERROR c.uhn.fhir.log.batch_troubleshooting [JobMaintenanceServiceImpl.java:206] Maintenance pass failed
ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException: HAPI-0826: The operation has failed with a version constraint failure. This generally means that two clients/threads were trying to update the same resource at the same time, and this request was chosen as the failing request.
at ca.uhn.fhir.jpa.config.HapiFhirHibernateJpaDialect.convertHibernateAccessException(HapiFhirHibernateJpaDialect.java:113)
at ca.uhn.fhir.jpa.config.HapiFhirHibernateJpaDialect.convertHibernateAccessException(HapiFhirHibernateJpaDialect.java:64)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:233)
at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:566)
...
Please note that the server works correctly, and it is able to fulfill the client requests.
The previous version of the JPA Server (6.1.0) didn't raise any exception about any scheduler.
The underlying database is Postgres 14.
Do you have any suggestions about the issue with this scheduler ?
Thanks
Andrea