Skip to content

[Bug][Flink] Read the live state instead of finalStatus when tracking Yarn applications - #4357

Open
niumy0701 wants to merge 1 commit into
apache:devfrom
niumy0701:bug-4356-update-yarn-state
Open

niumy0701 wants to merge 1 commit into
apache:devfrom
niumy0701:bug-4356-update-yarn-state

Conversation

@niumy0701

@niumy0701 niumy0701 commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request

Issue Number: relates to #4356

FlinkAppHttpWatcher#getStateFromYarn reads yarnAppInfo.getApp().getFinalStatus(). On a running Yarn application finalStatus is always UNDEFINED (it only takes a value such as SUCCEEDED/FAILED/KILLED once the application has terminated), so the state maps to FlinkAppStateEnum.OTHER and the status update is skipped. The console therefore shows an application jumping from STARTING straight to a terminal state — the intermediate states are never displayed.

This PR reads app.getState() instead, which carries the live Yarn state (RUNNING, FINISHED, FAILED, KILLED) and maps correctly while the application is still running.

The doPersistMetrics call in this path must also pass stopWatch=false — a companion change required by the first fix:

  • Before this PR, only terminal states could reach the call (running states never mapped), so stopWatch=true was harmless.
  • With the fix, intermediate states also reach the call, and stopWatch=true would unwatch the application while it is still running, freezing further status updates.
  • doPersistMetrics keeps unwatching terminal states on its own through the isEndState branch, so terminal-state handling is unaffected.

Note: #4356 was closed as completed, but both getFinalStatus() call sites are still present on current dev, and the UNDEFINED → OTHER skip mechanism still reproduces, so the fix is still needed.

Brief change log

  • getStateFromYarn: read yarnAppInfo.getApp().getState() instead of getFinalStatus() (2 call sites).
  • getStateFromYarn: pass stopWatch=false to doPersistMetrics in the running-state update path.
  • Add debug logs for the tracked appId and the REST URLs used by the watcher (no full response logging).

Verifying this change

This change is a bug fix in a watcher that requires a live Yarn/Flink REST endpoint, so it has no dedicated unit test. It can be verified as follows:

Does this pull request potentially affect one of the following parts

  • Dependencies (does it add or upgrade a dependency): no

@sonarqubecloud

sonarqubecloud Bot commented Jun 4, 2026

Copy link
Copy Markdown

… Yarn applications

FlinkAppHttpWatcher#getStateFromYarn reads yarnAppInfo.getApp().getFinalStatus().
On a running Yarn application finalStatus is always UNDEFINED, so the state
maps to FlinkAppStateEnum.OTHER and the status update is skipped: the console
shows the application jumping from STARTING straight to a terminal state,
and the intermediate states are never displayed (issue apache#4356).

Read app.getState() instead, which carries the live Yarn state (RUNNING,
FINISHED, FAILED, KILLED) and maps correctly while the application is
still running.

The doPersistMetrics call in this path must also pass stopWatch=false:
with the fix, intermediate states now reach this call, and the previous
stopWatch=true would unwatch the application while it is still running,
freezing further status updates. doPersistMetrics keeps unwatching terminal
states on its own through the isEndState branch.

Also add debug logs for the tracked appId and the REST URLs used by the
watcher (no full response logging).
@niumy0701
niumy0701 force-pushed the bug-4356-update-yarn-state branch from 5b76164 to 20ac54b Compare November 26, 2026 03:22
@sonarqubecloud

Copy link
Copy Markdown

@niumy0701 niumy0701 changed the title [bug-4356] After obtaining an exception in task status from Flink, th… [Bug][Flink] Read the live state instead of finalStatus when tracking Yarn applications Nov 26, 2026
@niumy0701

Copy link
Copy Markdown
Contributor Author

Hi @wolfboys, I've refreshed this PR (rebased onto the latest dev, removed the noisy full-result logging, and rewrote the commit message). The CI workflows are now awaiting approval (action_required) — could you please approve the workflow runs when you get a chance? The SonarCloud Quality Gate is green on the new head. Thanks!

@niumy0701

Copy link
Copy Markdown
Contributor Author

Hi @wolfboys, the workflows on this PR are still awaiting approval (action_required). Could you approve them when you get a moment? Thanks!

@niumy0701

Copy link
Copy Markdown
Contributor Author

Hi @wolfboys, gentle reminder: the workflows on this PR have been awaiting approval (action_required) since the Nov 26 rebase, and the SonarCloud Quality Gate is green on head 20ac54b. Could you approve the CI runs when you get a chance? Thanks!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant