[AMORO-4235] Fix the issue of optimizing tasks get stuck when stale ack arrives after task reset by OptimizerKeeper#4239
Open
zhangwl9 wants to merge 1 commit into
Conversation
…ter task reset by OptimizerKeeper
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4239 +/- ##
============================================
+ Coverage 23.09% 30.14% +7.04%
- Complexity 2706 4382 +1676
============================================
Files 463 680 +217
Lines 42826 55272 +12446
Branches 6044 7092 +1048
============================================
+ Hits 9891 16662 +6771
- Misses 32076 37352 +5276
- Partials 859 1258 +399
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are the changes needed?
Close #4235.
Root Cause
A race condition between two threads:
Thread OptimizerKeeper
Detects optimizer expired → 'OptimizerKeeper#retryTask()' → 'OptimizingQueue#reset()' sets token=null , status back to PLANNED
Optimizer Thread
Sends 'OptimizingQueue#ackTask()' request with old token → 'TaskRuntime#validThread()' sees token==null → throws TaskRuntimeException
The 'TaskRuntime#ack()' directly called 'TaskRuntime#validThread()' which throws an unrecoverable exception when token==null .
This exception causes the 'PersistentBase.doAsTransaction()' transaction to roll back, leaving the task in an inconsistent state and blocking the entire optimizing process for the table.
Brief change log
Replace the validThread(thread) call in ack() with a two-step guard:
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