VanHelxing commented on issue #13577:
URL: 
https://github.com/apache/dolphinscheduler/issues/13577#issuecomment-1457465070

   @liangkiller @unnunique @Amy0104 @QuantumXiecao @danielfree 
   
   this error is due to a caching problem,the first time the process definition 
is saved,the  task definition cache will caches null values。
   
   The next time you update the process definition,The task definition will 
have duplicate code and version data。
   
   **ProcessServiceImpl#saveTaskDefine**
   `public int saveTaskDefine(User operator, long projectCode, 
List<TaskDefinitionLog> taskDefinitionLogs,
                                 Boolean syncDefine) {
           Date now = new Date();
           List<TaskDefinitionLog> newTaskDefinitionLogs = new ArrayList<>();
           List<TaskDefinitionLog> updateTaskDefinitionLogs = new ArrayList<>();
           for (TaskDefinitionLog taskDefinitionLog : taskDefinitionLogs) {
               taskDefinitionLog.setProjectCode(projectCode);
               taskDefinitionLog.setUpdateTime(now);
               taskDefinitionLog.setOperateTime(now);
               taskDefinitionLog.setOperator(operator.getId());
               
taskDefinitionLog.setResourceIds(getResourceIds(taskDefinitionLog));
               if (taskDefinitionLog.getCode() == 0) {
                   
taskDefinitionLog.setCode(CodeGenerateUtils.getInstance().genCode());
               }
               if (taskDefinitionLog.getVersion() == 0) {
                   // init first version
                   taskDefinitionLog.setVersion(Constants.VERSION_FIRST);
               }
   
               # **  this query will caches null values **
               TaskDefinitionLog definitionCodeAndVersion = 
taskDefinitionLogMapper.queryByDefinitionCodeAndVersion(
                       taskDefinitionLog.getCode(), 
taskDefinitionLog.getVersion());
               if (definitionCodeAndVersion == null) {
                   taskDefinitionLog.setUserId(operator.getId());
                   taskDefinitionLog.setCreateTime(now);
                   newTaskDefinitionLogs.add(taskDefinitionLog);
                   continue;
               }
       
           ....
   `
   
   `@CacheConfig(cacheNames = "taskDefinition", keyGenerator = 
"cacheKeyGenerator")
   public interface TaskDefinitionLogMapper extends 
BaseMapper<TaskDefinitionLog> {
   
       /**
        * query task definition log
        *
        * @param code taskDefinitionCode
        * @param version version
        * @return task definition log
        */
      @Cacheable(sync = true)
       TaskDefinitionLog queryByDefinitionCodeAndVersion(@Param("code") long 
code, @Param("version") int version);
     
      ...
   `


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to