You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yarn-issues@hadoop.apache.org by "Jose Luis López (Jira)" <ji...@apache.org> on 2026/10/05 14:12:00 UTC
[jira] [Updated] (YARN-12004) Fix Router-vs-RM read races in TestRouterWebServicesREST
[ https://issues.apache.org/jira/browse/YARN-12004?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jose Luis López updated YARN-12004:
-----------------------------------
Description:
{{TestRouterWebServicesREST}} (and {{TestFederationWebApp}}, which extends it) fails intermittently on CI in {{testAppXML}}, {{testAppStateXML}}, {{testAppAttemptXML}} and {{testGetContainersXML}}, for example:
{noformat}
org.opentest4j.AssertionFailedError: expected: <ACCEPTED> but was: <SUBMITTED>
at ...TestRouterWebServicesREST.testAppStateXML(...)
{noformat}
Each of these tests submits an application, reads one value once through the Router and once directly from the RM, and asserts the two are equal. The value read is the AM host, the state, the attempts or the containers. The RM is still moving the new application through its lifecycle between the two reads, so the reads can legitimately differ.
h3. Proposed fix (test-only)
* Add a helper {{assertRouterMatchesRM(path, type, key)}}. Each try reads the RM, then the Router, then the RM again, and compares the {{key}} extracted from each answer:
** If the RM changed between its two reads, retry, up to 10s.
** If the RM was stable, the Router must match it. A Router that disagrees with a stable RM twice fails at once, so a broken Router cannot pass just because the RM's value eventually reaches whatever the Router reports.
* {{testAppXML}}, {{testAppStateXML}} and {{testAppAttemptXML}} use the helper. Keys are chosen so that a change followed by its reversal still looks like a change: for example, {{testAppXML}} compares the AM container log URL along with the AM host.
* {{testGetContainersXML}} compares container IDs rather than counts. It retries stable-looking mismatches instead of failing fast, because the endpoint reports only the current attempt's AM container. That container lives 20–100 ms in this setup, so it can appear and disappear within a single Router read.
* Replace the duplicated Router/RM request code with a single-address {{performGetCall}} that closes every client it creates.
* Raise the timeout of the affected tests from 2s to 30s.
was:
{{{}TestRouterWebServicesREST{}}}, and {{TestFederationWebApp}} which extends it, fail intermittently on CI because several tests do not wait for the RM's asynchronous application lifecycle.
h3. Symptoms
* {{getAppAttempt}} reads {{getAttempts().get(0)}} right after the submission returns, before the RM has created the first attempt, and throws {{{}IndexOutOfBoundsException{}}}. This affects {{testGetAppAttemptXML}} and {{{}testGetContainersXML{}}}, which {{testGetAppsMultiThread}} also calls.
* {{{}testAppXML{}}}, {{{}testAppStateXML{}}}, {{testAppAttemptXML}} and {{testGetContainersXML}} each compare one Router read with one RM read, taken one after the other, of a value the RM is still changing on a newly submitted application: the AM host, the application state, the number of attempts, the attempt's containers. Typical failures:
{noformat}
expected: <ACCEPTED> but was: <SUBMITTED>
expected: <0> but was: <1>
{noformat}
Looping {{{}testAppXML{}}}, {{testAppStateXML}} and {{testAppAttemptXML}} 3000 times each against unchanged trunk failed 8, 14 and 38 times respectively. Upstream CI on [https://github.com/apache/hadoop/pull/8681] (YARN-11984) failed in both {{TestFederationWebApp}} and {{TestRouterWebServicesREST}} for these reasons.
h3. Proposed fix (test code only)
* {{getAppAttempt}} waits, up to 10s, for the first attempt to appear.
* A new {{assertRouterMatchesRM}} helper reads the RM, then the Router, then the RM again.
** If the RM changed between its two reads, it retries.
** If the RM was stable, the Router must match it. A Router that disagrees with a stable RM twice fails at once, so a broken Router cannot pass just because the RM's value eventually reaches whatever the Router reports.
* The checks compare values that cannot repeat. {{testGetContainersXML}} compares container IDs instead of counts, which go 1, 0, 1 as one attempt fails and the next starts. {{testAppXML}} also compares the AM container log URL, which identifies the attempt.
* The tests that now wait get a 30s timeout instead of 2s. {{performGetCalls}} now closes the two clients it creates.
Tests that compare values which do not change after submission (priority, queue, timeouts, application counts) are unchanged. With the fix, looping each of the four methods 3200 times in three fresh JVMs failed none.
Summary: Fix Router-vs-RM read races in TestRouterWebServicesREST (was: Fix Router-vs-RM read races in TestRouterWebServicesREST and TestFederationWebApp)
> Fix Router-vs-RM read races in TestRouterWebServicesREST
> --------------------------------------------------------
>
> Key: YARN-12004
> URL: https://issues.apache.org/jira/browse/YARN-12004
> Project: Hadoop YARN
> Issue Type: Test
> Components: router, test
> Affects Versions: 3.6.0
> Reporter: Jose Luis López
> Priority: Minor
> Labels: pull-request-available
>
> {{TestRouterWebServicesREST}} (and {{TestFederationWebApp}}, which extends it) fails intermittently on CI in {{testAppXML}}, {{testAppStateXML}}, {{testAppAttemptXML}} and {{testGetContainersXML}}, for example:
> {noformat}
> org.opentest4j.AssertionFailedError: expected: <ACCEPTED> but was: <SUBMITTED>
> at ...TestRouterWebServicesREST.testAppStateXML(...)
> {noformat}
> Each of these tests submits an application, reads one value once through the Router and once directly from the RM, and asserts the two are equal. The value read is the AM host, the state, the attempts or the containers. The RM is still moving the new application through its lifecycle between the two reads, so the reads can legitimately differ.
> h3. Proposed fix (test-only)
> * Add a helper {{assertRouterMatchesRM(path, type, key)}}. Each try reads the RM, then the Router, then the RM again, and compares the {{key}} extracted from each answer:
> ** If the RM changed between its two reads, retry, up to 10s.
> ** If the RM was stable, the Router must match it. A Router that disagrees with a stable RM twice fails at once, so a broken Router cannot pass just because the RM's value eventually reaches whatever the Router reports.
> * {{testAppXML}}, {{testAppStateXML}} and {{testAppAttemptXML}} use the helper. Keys are chosen so that a change followed by its reversal still looks like a change: for example, {{testAppXML}} compares the AM container log URL along with the AM host.
> * {{testGetContainersXML}} compares container IDs rather than counts. It retries stable-looking mismatches instead of failing fast, because the endpoint reports only the current attempt's AM container. That container lives 20–100 ms in this setup, so it can appear and disappear within a single Router read.
> * Replace the duplicated Router/RM request code with a single-address {{performGetCall}} that closes every client it creates.
> * Raise the timeout of the affected tests from 2s to 30s.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: yarn-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: yarn-issues-help@hadoop.apache.org