fix: make tidy workflow state updates idempotent
This commit is contained in:
@@ -134,6 +134,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
update alg.tidy_workflow
|
||||
set status = 'COMPLETED', completed_at = SYSUTCDATETIME(), updated_at = SYSUTCDATETIME()
|
||||
where workflow_id = #{workflowId}
|
||||
and status not in ('COMPLETED', 'CANCELLED_RECONCILED')
|
||||
and not exists (select 1 from alg.tidy_step where workflow_id = #{workflowId} and status <> 'COMPLETED')
|
||||
</update>
|
||||
|
||||
@@ -146,7 +147,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<update id="pauseTidyWorkflow">
|
||||
update alg.tidy_workflow
|
||||
set status = 'PAUSED_RECOVERY', status_reason = #{statusReason}, updated_at = SYSUTCDATETIME()
|
||||
where workflow_id = #{workflowId} and status not in ('COMPLETED', 'CANCELLED_RECONCILED')
|
||||
where workflow_id = #{workflowId}
|
||||
and status not in ('PAUSED_RECOVERY', 'COMPLETED', 'CANCELLED_RECONCILED')
|
||||
</update>
|
||||
|
||||
<update id="pauseTidyStep">
|
||||
|
||||
@@ -172,6 +172,18 @@ class WmsAlgorithmMapperWorkflowSqlTest {
|
||||
.contains("resultmap=\"tidyworkflowstatemap\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
void tidyWorkflowCompletionDoesNotRewriteTerminalRows() throws IOException {
|
||||
assertThat(statement("update", "completeTidyWorkflow"))
|
||||
.contains("status not in ('completed', 'cancelled_reconciled')");
|
||||
}
|
||||
|
||||
@Test
|
||||
void tidyWorkflowPauseDoesNotRewriteAlreadyPausedOrTerminalRows() throws IOException {
|
||||
assertThat(statement("update", "pauseTidyWorkflow"))
|
||||
.contains("status not in ('paused_recovery', 'completed', 'cancelled_reconciled')");
|
||||
}
|
||||
|
||||
@Test
|
||||
void tidyRecoveryProjectionMapsWorkflowJobInventoryAndLockEvidence() throws IOException {
|
||||
String mapping = statement("resultmap", "tidyRecoveryEvidenceMap");
|
||||
|
||||
Reference in New Issue
Block a user