github-actions[bot] commented on issue #10381: URL: https://github.com/apache/dolphinscheduler/issues/10381#issuecomment-1150770094
### 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 In version 2.0.5, creating a new task and clicking to save t_ds_process_definition_log multiple times will generate multiple identical tasks, resulting in an abnormal workflow definition. Because the saved task does not return the tast code to the front-end, update the front-end json, and submit the json multiple times, the task will be recognized as a new task and saved in mysql, thus saving multiple pieces of data ### What you expected to happen Expect to create a new task, click save multiple times, t_ds_process_definition_log will not save this data ### How to reproduce 2 solutions, One is to return the taskId and version generated after saving to the front end, and the next time you click save, this part of the information will be carried Second, modify the saveTaskDefine of ProcessService.class, change the version to 1 first, do not go to the database with version=0 to determine whether it needs to be updated, so that no data will be found, we first set the version to 1, and then go to the database Check whether this information exists in it. If it exists, it will only be updated, not added. The code is as follows ```` 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]
