pratapaditya04 opened a new pull request, #4203: URL: https://github.com/apache/gobblin/pull/4203
## Problem `GobblinYarnAppLauncher` monitors the submitted YARN application on a background, **non-daemon** `ScheduledExecutorService` and returns from `launch()` right after submission. For the Azkaban / Grid-Gateway submitter path (`AzkabanGobblinYarnAppLauncher.run()` → `launch()`), `run()` therefore returns at *submission* time while the launcher-owned non-daemon threads (the status monitor, the `ServiceManager`, the YARN client) stay alive for the entire job. The submitter JVM never exits on its own, so the orchestrator's watchdog force-kills it — surfacing as a spurious cancellation. Two further issues with the background-monitor design: - The monitor's terminal handler calls `stop()` **from the monitor's own worker thread**, and `stop()` then calls `shutdownExecutorService(applicationStatusMonitor)` — a thread cannot await its own executor's termination, so teardown stalls for the full `awaitTermination` window. - `main()` calls `launch()` then `System.exit(getExitCode())`; with a non-blocking `launch()` that exit raced submission. ## Fix Drive the application-status poll **synchronously in the calling (`launch()` / `run()`) thread** and remove the background monitor entirely. In attached mode `launch()` now loops — reusing the existing `ApplicationReportArrivalEvent` / `GetApplicationReportFailureEvent` `@Subscribe` handlers via the synchronous `EventBus` — until the application reaches a terminal state, or the launcher is otherwise stopped (graceful shutdown or lost-AM visibility), then tears down. Consequences: - `launch()` now represents the full application lifecycle (not just submission). Once it returns there are no launcher-owned non-daemon threads left, so the submitter JVM exits cleanly; this also makes `main()`'s `System.exit(getExitCode())` correct. - No background executor → no self-shutdown stall. - An interrupt (Azkaban `cancel()`) ends the wait and lets the cancel/stop path own the terminal status. - The loop also exits on `stopped`, so the lost-AM-visibility path (which stops the launcher without setting `applicationCompleted`) cannot block forever. - **Detached launches are unchanged** — they skip the wait and return right after submission, leaving the application running. The `applicationStatusMonitor` field, its initialization, and its shutdown in `stop()` are removed. ## Compatibility The only callers of `launch()` are `main()` and `AzkabanGobblinYarnAppLauncher.run()`, both of which want blocking behaviour; there are no OSS subclasses of `GobblinYarnAppLauncher`. Detached-mode behaviour is preserved. ## Tests `:gobblin-yarn:compileJava` clean; existing `GobblinYarnAppLauncherTerminalGteTest` passes. Adds three blocking-loop unit tests: terminal-immediate, poll-until-complete, and a regression guard that the loop exits on `stopped` alone (lost-AM-visibility path). 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
