seoyoniee opened a new issue, #4139: URL: https://github.com/apache/amoro/issues/4139
### Search before asking - [x] I have searched in the [issues](https://github.com/apache/amoro/issues?q=is%3Aissue) and found no similar issues. ### What would you like to be improved? When releasing an optimizer via `DELETE /api/ams/v1/optimize/optimizers/{jobId}`, a `NullPointerException` is thrown if the `resource` table entry is missing. ### Root cause `deleteResource` and `deleteOptimizer` are executed as two separate DB operations without a transaction: ```java optimizerManager.deleteResource(resourceId); // step 1 optimizerManager.deleteOptimizer(resource.getGroupName(), resourceId); // step 2 ``` If step 1 succeeds but step 2 fails, the resource row is deleted while the optimizer row remains. On the next release attempt, getResource() returns null and the following line throws NPE: ``` Resource resource = optimizerManager.getResource(resourceId); // null resource.getProperties().putAll(...); // NPE ``` ### How should we improve? Both operations should be executed atomically in a single transaction to prevent inconsistent state. If resource is already missing due to a previous partial failure, the release should handle it gracefully using OptimizerInstance fields instead of failing with NPE. ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Subtasks _No response_ ### 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]
