lsy1072915121 opened a new issue, #12872: URL: https://github.com/apache/dolphinscheduler/issues/12872
### 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 工作流版本信息记录中,会把没有内容变化的工作流保存操作,也记录一条版本信息。在源码中发现,开发者已经有意把没有修改的保存操作过滤掉,但实际上并不起效果。 ### What you expected to happen 正常来说,工作流在没有修改的情况下保存,应该是不需要记录版本信息的。 ### How to reproduce <img width="1219" alt="iShot2022-11-11 19 37 19" src="https://user-images.githubusercontent.com/20608690/201332707-b075cf15-799a-4b67-bd64-5c61e578c68c.png"> 创建一个工作流,会有一个v1版本记录。 <img width="1386" alt="iShot2022-11-11 19 39 53" src="https://user-images.githubusercontent.com/20608690/201338847-78f74a97-3067-4237-8974-1361f5e4d9de.png"> 再次打开这个工作流,在工作流没有任何修改的情况下,点击保存 <img width="1244" alt="iShot2022-11-11 19 41 10" src="https://user-images.githubusercontent.com/20608690/201338976-ee27590d-846c-4373-9bf7-6d264b15471d.png"> 仍会有一条版本信息被记录下来。 ### Anything else # 研究源码后找到了原因,提供参考 <img width="1199" alt="iShot2022-11-11 19 50 42" src="https://user-images.githubusercontent.com/20608690/201334747-01d58d22-7692-4da8-848b-ef0032aadc31.png"> 这部分代码中可以看出,本意是有过滤无修改的保存操作的。 <img width="1184" alt="iShot2022-11-11 19 53 58" src="https://user-images.githubusercontent.com/20608690/201335227-a2de2749-af57-4dd2-a04e-319b39524331.png"> 但是在这一步中,即使无操作保存,这里的isChange也会是true,原因是removeAll出了问题。 <img width="1372" alt="iShot2022-11-11 19 57 13" src="https://user-images.githubusercontent.com/20608690/201336064-9910432c-0caa-41a4-a62b-0f202aa8d5d9.png"> 可以看到,ProcessTaskRelationLog覆写hashCode方法是调用了ProcessTaskRelation的hashCode,而hashCode中是对name, processDefinitionVersion, projectCode, processDefinitionCode, preTaskCode, preTaskVersion, postTaskCode, postTaskVersion 等参数取hash值。 <img width="1237" alt="iShot2022-11-11 20 04 07" src="https://user-images.githubusercontent.com/20608690/201336830-bd537993-395e-4c21-8731-b7d4f5d675d5.png"> 实际上,前端传了的taskDefinitionJson中是不包含 processDefinitionVersion, projectCode,processDefinitionCode这是三个参数,removeAll出错,一直被误认为isChange,最终导致无修改操作也会有版本记录。 # 解决办法 前端把那三个参数带上,就可以了,下次无修改保存后就不会记录版本信息了。 ### Version 2.0.x ### Are you willing to submit PR? - [X] 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]
