amoro
amoro copied to clipboard
[bug]:TaskRuntime.stateLock and TableOptimizingProcess.lock can cause deadlocks.
Why are the changes needed?
TaskRuntime.stateLock and TableOptimizingProcess.lock can cause deadlocks.This can cause tables in a certain resource group to malfunction, and OptimizerKeeper will also fail to function properly.
Close #4001.
Brief change log
Fixes Implemented:
The following fixes have been implemented:
- Modified the
completeTaskmethod (lines 565-577):
- First, call
taskRuntime.complete()(acquire and release the database lock). - After the database lock is released, acquire
TableOptimizingProcess.this.lockand callacceptResult. - Ensure the lock acquisition order is consistent: acquire
TableOptimizingProcess.this.lockfirst, then acquire the database lock.
- Removed the
whenCompletedcallback registration (lines 910-922 and 932-945):
- Avoid synchronously calling
acceptResultwhile holding the database lock. - Instead, explicitly call
acceptResultwithincompleteTask.
- Modified the
cancelTasksmethod (lines 897-902):
-
First, cancel all tasks (acquire and release the database lock).
-
Then call
acceptResultfor each canceled task (while holdingTableOptimizingProcess.this.lock).
How was this patch tested?
-
[ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
-
[ ] Add screenshots for manual tests if appropriate
-
[ ] Run test locally before making a pull request
Documentation
- Does this pull request introduce a new feature? (yes / no)
- If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)