Search before asking
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:
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?
Subtasks
No response
Code of Conduct
Search before asking
What would you like to be improved?
When releasing an optimizer via
DELETE /api/ams/v1/optimize/optimizers/{jobId}, aNullPointerExceptionis thrown if theresourcetable entry is missing.Root cause
deleteResourceanddeleteOptimizerare executed as two separate DB operations without a transaction: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:
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?
Subtasks
No response
Code of Conduct