j1wonpark opened a new pull request, #4090:
URL: https://github.com/apache/amoro/pull/4090

   ## Summary
   - Reset SCHEDULED/ACKED tasks to PLANNED during AMS recovery in 
`loadTaskRuntimes()`, so they are re-queued for execution instead of being 
silently ignored
   - Fix race condition in `OptimizerKeeper` by moving `unregisterOptimizer()` 
before `collectTasks()`, so expired optimizer tokens are removed from 
`authOptimizers` before orphaned task detection runs
   
   resolve #4089
   
   ## Changes
   
   ### `OptimizingQueue.java` (`loadTaskRuntimes`)
   When AMS restarts and recovers in-flight processes from DB, tasks in 
SCHEDULED or ACKED state were only loaded into `taskMap` but never placed into 
`taskQueue`. Since the original Optimizer connection is lost after restart, 
these tasks could never complete, causing the table to remain stuck in 
`MAJOR_OPTIMIZING` status permanently.
   
   Now SCHEDULED/ACKED tasks are reset to PLANNED and re-queued during recovery.
   
   ### `DefaultOptimizingService.java` (`OptimizerKeeper.run`)
   The `OptimizerKeeper` scanned for orphaned tasks **before** removing the 
expired optimizer's token from `authOptimizers`. This caused the predicate 
`!activeTokens.contains(task.getToken())` to evaluate to `false`, preventing 
orphaned tasks from being detected. After `unregisterOptimizer` removed the 
token, no further keeper events were generated.
   
   Now `unregisterOptimizer()` is called before `collectTasks()` so the expired 
token is no longer in `activeTokens` during the scan.
   
   ### `TestDefaultOptimizingService.java`
   Updated `testTouchTimeout`, `testReloadScheduledTask`, and 
`testReloadAckTask` to reflect the new recovery behavior where SCHEDULED/ACKED 
tasks are reset to PLANNED.
   
   ## Test plan
   - [x] `TestDefaultOptimizingService` — all 13 tests pass


-- 
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]

Reply via email to