[ 
https://issues.apache.org/jira/browse/HADOOP-20097?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ferenc Erdelyi updated HADOOP-20097:
------------------------------------
    Component/s: yarn

> Finished app lingers in runningApplications after NM reconnect
> --------------------------------------------------------------
>
>                 Key: HADOOP-20097
>                 URL: https://issues.apache.org/jira/browse/HADOOP-20097
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: yarn
>            Reporter: Ferenc Erdelyi
>            Priority: Major
>
> When a NM reconnects and reports its running applications (e.g. NM restart 
> with recovery enabled), {{RMNodeImpl}} can end up tracking the same 
> application twice. Once the application finishes, only one of the two entries 
> is removed, so the node keeps a finished app in its running list.
> Impact: e.g. on graceful decommission: the node never becomes idle in the 
> RM's eyes, so it stays DECOMMISSIONING until the timeout 
> ({{yarn.resourcemanager.nodemanager-graceful-decommission-timeout-secs}}), or 
> forever if the timeout is negative.
> h3. Cause
> {{runningApplications}} is a {{List}} (added in YARN-3445). On reconnect, 
> {{ReconnectNodeTransition}} calls {{handleRunningAppOnNode()}} for every 
> reported app, and that method adds without checking whether the app is 
> already there. It usually is, from earlier heartbeats. 
> {{CleanUpAppTransition}} later calls {{List.remove()}}, which drops just one 
> occurrence.
> The stale entry stays until the {{RMNodeImpl}} is replaced (re-registration 
> after DECOMMISSIONED/LOST/REBOOTED, a reconnect on a different HTTP port, or 
> an RM restart/failover).
> h3. How to reproduce
> On a cluster with NM recovery enabled: run an app with containers on node N, 
> restart the NM on N while the app is running, let the app finish, then 
> gracefully decommission N. It stays DECOMMISSIONING. The RM never logs {{No 
> containers running on N. Attempting to deactivate decommissioning node.}}
> New unit tests in {{TestRMNodeTransitions}}, run without the fix:
> {noformat}
> testDecommissioningAfterReconnectWithFinishedApp:1000 expected: 
> <DECOMMISSIONED> but was: <DECOMMISSIONING>
> testReconnectWithNewRunningAppDoesNotDuplicateApp:980 expected: 
> <[application_0_0001]> but was: <[application_0_0001, application_0_0001]>
> testReconnectWithRunningAppDoesNotLeaveStaleApp:955 expected: 
> <[application_0_0001]> but was: <[application_0_0001, application_0_0001]>
> {noformat}
> h3. Workaround
> Wait for the timeout, restart the NM once the app has finished on it (a 
> DECOMMISSIONING node that reconnects with no apps is decommissioned right 
> away), or decommission the node forcefully.
> h3. Fix proposal
> Only add the app if it isn't tracked yet:
> {code:java}
> -    rmNode.runningApplications.add(appId);
> +    if (!rmNode.runningApplications.contains(appId)) {
> +      rmNode.runningApplications.add(appId);
> +    }
> {code}
> The {{RMAppRunningOnNodeEvent}} is still sent every time on purpose: for an 
> app that has already finished, the RMApp answers with 
> {{RMNodeCleanAppEvent}}, which is what cleans up a stale entry when the NM 
> still reports the app.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to