This is an automated email from the ASF dual-hosted git repository.

caishunfeng pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 13af2adfc1 [fix] Fix the  SERIAL_DISCARD execution_type not working 
(#10258)
13af2adfc1 is described below

commit 13af2adfc150e6e16ce07c5d1abeeb25f9cd9340
Author: cadl <[email protected]>
AuthorDate: Mon May 30 09:54:15 2022 +0800

    [fix] Fix the  SERIAL_DISCARD execution_type not working (#10258)
    
    * fix always stop process_instance when execution_type is SERIAL_DISCARD
    
    * test: no running_process, submit it
---
 .../dolphinscheduler/service/process/ProcessServiceImpl.java       | 7 +++++--
 .../dolphinscheduler/service/process/ProcessServiceTest.java       | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git 
a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
 
b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
index 20058539a1..5d66e11ff0 100644
--- 
a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
+++ 
b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
@@ -333,10 +333,13 @@ public class ProcessServiceImpl implements ProcessService 
{
         } else if (processDefinition.getExecutionType().typeIsSerialDiscard()) 
{
             List<ProcessInstance> runningProcessInstances = 
this.processInstanceMapper.queryByProcessDefineCodeAndProcessDefinitionVersionAndStatusAndNextId(processInstance.getProcessDefinitionCode(),
                     processInstance.getProcessDefinitionVersion(), 
Constants.RUNNING_PROCESS_STATE, processInstance.getId());
-            if (CollectionUtils.isEmpty(runningProcessInstances)) {
+            if (CollectionUtils.isNotEmpty(runningProcessInstances)) {
                 processInstance.setState(ExecutionStatus.STOP);
                 saveProcessInstance(processInstance);
+                return;
             }
+            processInstance.setState(ExecutionStatus.SUBMITTED_SUCCESS);
+            saveProcessInstance(processInstance);
         } else if 
(processDefinition.getExecutionType().typeIsSerialPriority()) {
             List<ProcessInstance> runningProcessInstances = 
this.processInstanceMapper.queryByProcessDefineCodeAndProcessDefinitionVersionAndStatusAndNextId(processInstance.getProcessDefinitionCode(),
                     processInstance.getProcessDefinitionVersion(), 
Constants.RUNNING_PROCESS_STATE, processInstance.getId());
@@ -3064,4 +3067,4 @@ public class ProcessServiceImpl implements ProcessService 
{
         K8s k8s = k8sMapper.selectOne(nodeWrapper);
         return k8s.getK8sConfig();
     }
-}
\ No newline at end of file
+}
diff --git 
a/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/process/ProcessServiceTest.java
 
b/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/process/ProcessServiceTest.java
index 47bdca17d1..0c9ddfbc7f 100644
--- 
a/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/process/ProcessServiceTest.java
+++ 
b/dolphinscheduler-service/src/test/java/org/apache/dolphinscheduler/service/process/ProcessServiceTest.java
@@ -421,7 +421,7 @@ public class ProcessServiceTest {
         Mockito.when(commandMapper.deleteById(7)).thenReturn(1);
         
Mockito.when(processInstanceMapper.queryByProcessDefineCodeAndProcessDefinitionVersionAndStatusAndNextId(11L,
 1, Constants.RUNNING_PROCESS_STATE, 224)).thenReturn(null);
         ProcessInstance processInstance8 = 
processService.handleCommand(logger, host, command7);
-        Assert.assertTrue(processInstance8 == null);
+        Assert.assertTrue(processInstance8 != null);
 
         ProcessDefinition processDefinition2 = new ProcessDefinition();
         processDefinition2.setId(123);

Reply via email to