fix batch intermittent and status update atomicity (#3773)

* fix intermittent and status update atomicity

* change log

Co-authored-by: Ken Stevens <ken@smilecdr.com>
This commit is contained in:
Ken Stevens 2022-07-09 08:51:04 -04:00 committed by GitHub
parent 61d34ab695
commit 839a1b53e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View File

@ -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."

View File

@ -34,7 +34,7 @@ import java.util.Set;
public interface IBatch2JobInstanceRepository extends JpaRepository<Batch2JobInstanceEntity, String>, 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

View File

@ -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());