baoyingcong opened a new issue, #10381: URL: https://github.com/apache/dolphinscheduler/issues/10381
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened 2.0.5版本,新建任务,多次点击保存t_ds_process_definition_log会生成多条一样的任务,导致工作流定义异常。 因为保存的任务并没有把tast的code返回前端,更新前端的json,多次提交的json,task会被识别成一个新的任务保存到mysql里面去,这样就存了多条数据 ### What you expected to happen 期望新建任务,多次点击保存,t_ds_process_definition_log 不会保存这条数据 ### How to reproduce 2种解决方案, 一、是将保存以后生成的taskId和version返回前端,下次点击保存,会携带这部分信息 二、修改 ProcessService.class 的saveTaskDefine,把先把version改为1,不要那version=0去数据库里面判断是否需要更新,这样是不会查到任何数据的,我们先置version为1,再去数据库里面查这条信息是否存在,如果存在那么就只更新,不新增,代码如下 ``` if (taskDefinitionLog.getVersion() <= 0){ taskDefinitionLog.setVersion(Constants.VERSION_FIRST); } if (taskDefinitionLog.getCode() > 0) { TaskDefinitionLog definitionCodeAndVersion = taskDefinitionLogMapper.queryByDefinitionCodeAndVersion(taskDefinitionLog.getCode(), taskDefinitionLog.getVersion()); if (definitionCodeAndVersion != null) { if (!taskDefinitionLog.equals(definitionCodeAndVersion)) { taskDefinitionLog.setUserId(definitionCodeAndVersion.getUserId()); Integer version = taskDefinitionLogMapper.queryMaxVersionForDefinition(taskDefinitionLog.getCode()); taskDefinitionLog.setVersion(version + 1); taskDefinitionLog.setCreateTime(definitionCodeAndVersion.getCreateTime()); updateTaskDefinitionLogs.add(taskDefinitionLog); } continue; } } ``` ### Anything else _No response_ ### Version 2.0.5 ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- 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]
