Browse Source

[Bug][API] fix genTaskCodeList return same code and save proces error (#6150)

* fix mysql create sentence bug

* fix mysql create sentence bug

* fix genTaskCodeList return same code and save proces error

Co-authored-by: JinyLeeChina <297062848@qq.com>
JinyLeeChina 3 years ago
parent
commit
e8ddc9103d

+ 5 - 4
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java

@@ -46,7 +46,6 @@ import org.apache.dolphinscheduler.common.utils.SnowFlakeUtils;
 import org.apache.dolphinscheduler.common.utils.SnowFlakeUtils.SnowFlakeException;
 import org.apache.dolphinscheduler.common.utils.StringUtils;
 import org.apache.dolphinscheduler.dao.entity.DagData;
-import org.apache.dolphinscheduler.dao.entity.ProcessData;
 import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
 import org.apache.dolphinscheduler.dao.entity.ProcessDefinitionLog;
 import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
@@ -287,9 +286,11 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
                 Set<Long> postTaskCodes = taskRelationList.stream().map(ProcessTaskRelationLog::getPostTaskCode).collect(Collectors.toSet());
                 Set<Long> taskNodeCodes = taskNodeList.stream().map(TaskNode::getCode).collect(Collectors.toSet());
                 Collection<Long> codes = CollectionUtils.subtract(postTaskCodes, taskNodeCodes);
-                logger.error("the task code is not exit");
-                putMsg(result, Status.TASK_DEFINE_NOT_EXIST, StringUtils.join(codes, Constants.COMMA));
-                return result;
+                if (CollectionUtils.isNotEmpty(codes)) {
+                    logger.error("the task code is not exit");
+                    putMsg(result, Status.TASK_DEFINE_NOT_EXIST, StringUtils.join(codes, Constants.COMMA));
+                    return result;
+                }
             }
             if (graphHasCycle(taskNodeList)) {
                 logger.error("process DAG has cycle");

+ 4 - 4
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/SnowFlakeUtils.java

@@ -23,7 +23,7 @@ import java.util.Objects;
 
 public class SnowFlakeUtils {
     // start timestamp
-    private static final long START_TIMESTAMP = 1609430400L; //2021-01-01
+    private static final long START_TIMESTAMP = 1609430400000L; //2021-01-01 00:00:00
     // Number of digits
     private static final long SEQUENCE_BIT = 13;
     private static final long MACHINE_BIT = 2;
@@ -67,8 +67,8 @@ public class SnowFlakeUtils {
         }
         lastTimestamp = currStmp;
         return (currStmp - START_TIMESTAMP) << TIMESTAMP_LEFT
-                | machineId << MACHINE_LEFT
-                | sequence;
+            | machineId << MACHINE_LEFT
+            | sequence;
     }
 
     private long getNextMill() {
@@ -80,7 +80,7 @@ public class SnowFlakeUtils {
     }
 
     private long nowTimestamp() {
-        return System.currentTimeMillis() / 1000;
+        return System.currentTimeMillis();
     }
 
     public static class SnowFlakeException extends Exception {