From 8d39e3466c5b21fa1a93344627a0c860a954d557 Mon Sep 17 00:00:00 2001 From: Emre Dincturk <74370953+mrdnctrk@users.noreply.github.com> Date: Thu, 24 Aug 2023 10:41:01 -0400 Subject: [PATCH] cast errorcount to string for batchjob failure message (#5230) (#5233) Co-authored-by: Emre Dincturk --- ...ch2-job-cannot-transition-to-failed-status-on-mssql.yaml | 6 ++++++ .../java/ca/uhn/fhir/jpa/batch2/JpaJobPersistenceImpl.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 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 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);