[AMORO-4198][optimizer] Support graceful shutdown for in-progress tasks#4197
[AMORO-4198][optimizer] Support graceful shutdown for in-progress tasks#4197j1wonpark wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4197 +/- ##
============================================
+ Coverage 23.09% 30.24% +7.14%
- Complexity 2706 4390 +1684
============================================
Files 463 680 +217
Lines 42826 55337 +12511
Branches 6044 7102 +1058
============================================
+ Hits 9891 16735 +6844
- Misses 32076 37337 +5261
- Partials 859 1265 +406
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:
|
On SIGTERM the optimizer flips its stopped flag and returns immediately, so in-flight task results are silently dropped (completeTask is gated by isStarted). On K8s this is compounded by `sh -c` swallowing SIGTERM, a 30s default grace period, and Hadoop's FileSystem cache cleanup racing JVM shutdown hooks. - Optimizer.stopOptimizing: join executors with a deadline, force interrupt only on timeout; keep toucher alive so AMS heartbeats continue while tasks drain. - OptimizerExecutor.completeTask: best-effort direct call after stop so the in-flight result still reaches AMS. - SparkOptimizer / StandaloneOptimizer: register on Hadoop ShutdownHookManager (priority above FS_CACHE / SparkContext) with an explicit per-hook timeout. - OptimizerConfig: new -st / --shutdown-timeout-ms (default 600s). - KubernetesOptimizerContainer: `sh -c 'exec <args>'` and an explicit terminationGracePeriodSeconds derived from -st + 30s buffer; user podTemplate values are respected. - optimizer.sh start-foreground: exec $CMDS so java gets PID 1. Signed-off-by: Jiwon Park <jpark92@outlook.kr>
3607baa to
2a6df8f
Compare
|
Gentle ping for review 🙏 @zhoujinsong @czy006 — this builds on the master-slave optimizer work you reviewed in #4174 / #3937, and you both merged |
Why are the changes needed?
Close #4198.
When an optimizer receives SIGTERM, in-progress tasks are silently dropped and
AMS re-schedules them — doubling work and potentially causing duplicate commits.
Brief change log
Optimizer.stopOptimizing(): join executor threads up to--shutdown-timeout-ms(default 10 min); keep toucher alive during drain so AMS heartbeats continue
OptimizerExecutor.completeTask(): best-effort direct call after shutdown soresults are not silently dropped
OptimizerToucher.stop(): interrupt runner thread to wake it from sleep immediatelyAbstractOptimizerOperator.waitAShortTime(): preserve interrupt flagOptimizerConfig: new-st/--shutdown-timeout-msoptionStandaloneOptimizer/SparkOptimizer: register graceful shutdown hook onHadoop's
ShutdownHookManageraboveFS_CACHEpriority with explicit timeoutKubernetesOptimizerContainer:execprefix in container command; deriveterminationGracePeriodSecondsfrom shutdown-timeout-ms + 30s bufferoptimizer.sh start-foreground:exec $CMDSso Java receives SIGTERM directlyHow 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
usagestring