diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_1_0/3773-batch2-state-change.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_1_0/3773-batch2-state-change.yaml new file mode 100644 index 00000000000..f0d78f2a9a0 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_1_0/3773-batch2-state-change.yaml @@ -0,0 +1,5 @@ +--- +type: fix +issue: 3773 +title: "A batch2 state change regression was introduced recently that resulted in batch2 jobs not being properly +completed. This has been corrected." diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IBatch2JobInstanceRepository.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IBatch2JobInstanceRepository.java index 929efe5e330..3be32006781 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IBatch2JobInstanceRepository.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/IBatch2JobInstanceRepository.java @@ -34,7 +34,7 @@ import java.util.Set; public interface IBatch2JobInstanceRepository extends JpaRepository, IHapiFhirJpaRepository { @Modifying - @Query("UPDATE Batch2JobInstanceEntity e SET e.myStatus = :status WHERE e.myId = :id") + @Query("UPDATE Batch2JobInstanceEntity e SET e.myStatus = :status WHERE e.myId = :id and e.myStatus <> :status") int updateInstanceStatus(@Param("id") String theInstanceId, @Param("status") StatusEnum theStatus); @Modifying diff --git a/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/batch2/JpaJobPersistenceImplTest.java b/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/batch2/JpaJobPersistenceImplTest.java index a2e1d47f032..51761c15b4a 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/batch2/JpaJobPersistenceImplTest.java +++ b/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/batch2/JpaJobPersistenceImplTest.java @@ -402,7 +402,8 @@ public class JpaJobPersistenceImplTest extends BaseJpaR4Test { public void testMarkInstanceAsCompleted() { String instanceId = mySvc.storeNewInstance(createInstance()); - mySvc.markInstanceAsCompleted(instanceId); + assertTrue(mySvc.markInstanceAsCompleted(instanceId)); + assertFalse(mySvc.markInstanceAsCompleted(instanceId)); runInTransaction(() -> { Batch2JobInstanceEntity entity = myJobInstanceRepository.findById(instanceId).orElseThrow(() -> new IllegalArgumentException());