diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_0_0/5230-batch2-job-cannot-transition-to-failed-status-on-mssql.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_0_0/5230-batch2-job-cannot-transition-to-failed-status-on-mssql.yaml new file mode 100644 index 00000000000..2994ffbe2d9 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_0_0/5230-batch2-job-cannot-transition-to-failed-status-on-mssql.yaml @@ -0,0 +1,6 @@ +--- +type: fix +issue: 5230 +title: "batch2 jobs on MS SQL Server were failing to transition to FAILED state after max retrials + for the job are exhausted. This is now fixed." + diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch2/JpaJobPersistenceImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch2/JpaJobPersistenceImpl.java index 73547c79245..01fe091dbbe 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch2/JpaJobPersistenceImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/batch2/JpaJobPersistenceImpl.java @@ -300,7 +300,7 @@ public class JpaJobPersistenceImpl implements IJobPersistence { Validate.isTrue(changeCount > 0, "changed chunk matching %s", chunkId); Query query = myEntityManager.createQuery("update Batch2WorkChunkEntity " + "set myStatus = :failed " - + ",myErrorMessage = CONCAT('Too many errors: ', myErrorCount, '. Last error msg was ', myErrorMessage) " + + ",myErrorMessage = CONCAT('Too many errors: ', CAST(myErrorCount as string), '. Last error msg was ', myErrorMessage) " + "where myId = :chunkId and myErrorCount > :maxCount"); query.setParameter("chunkId", chunkId); query.setParameter("failed", WorkChunkStatusEnum.FAILED);