Repository navigation
YARN-12069. TestFederationInterceptorREST#testReplaceLabelsOnNode is flaky: subcluster selection can return a subcluster that does not own the node - #9019
Conversation
…flaky: subcluster selection can return a subcluster that does not own the node. Contributed by José Luis López. Co-Authored-By: Claude <noreply@anthropic.com>
slfan1989
left a comment
There was a problem hiding this comment.
Could we add a case where one subcluster lookup fails and the others report that the node is absent? Since both outcomes are discarded here, the Router returns 404 even when it couldn't check the subcluster that owns the node.
… in the node fan-out. A subcluster whose node lookup fails (unreachable or erroring RM) used to collapse with a subcluster that answered 'node absent', so the Router returned 404 even when it had not checked the subcluster owning the node (review of YARN-12069). getNode(Collection, String) now reports answers and failed lookups separately: getNodeSubcluster and getNode(String) throw NotFoundException only when every subcluster answered, and a YarnRuntimeException (5xx semantics) when the fan-out is indeterminate. New test covers the mixed case: one subcluster fails, the others report the node absent. Contributed by José Luis López.
|
Good catch — agreed. A subcluster whose lookup fails was collapsed with one that answered "node absent", so the Router returned 404 even when the subcluster owning the node was never checked. I've fixed |
|
💔 -1 overall
This message was automatically generated. |
…etry and drop unused import. getNode(String) now reports a YarnRuntimeException instead of a 404 when subcluster lookups fail, because the subcluster owning the node may not have been checked. testGetNodeOneBadSC and testGetNodeTwoBadSCs still expected NotFoundException with only failing subclusters; they now assert the indeterminate-lookup error and the ids of the failed subclusters, consistent with testGetNodesOneBadSC. Also remove the commons-lang3 Pair import left unused by the node fan-out rewrite (checkstyle UnusedImports). Contributed by José Luis López. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018ArokScc4zSVGdkpfE16M9
|
🎊 +1 overall
This message was automatically generated. |
TestFederationInterceptorREST#testReplaceLabelsOnNodefails intermittently in full-class runs with a randomly chosen subcluster (subCluster#0,#1or#2instead of#3), while passing in isolation. Two defects inFederationInterceptorRESTcombine:getNode(...)fans out to the subclusters with a parallel stream and collects into a plainHashMapviaforEach— the consumer runs concurrently on ForkJoinPool threads, and concurrentHashMap.putsilently drops entries. When the node owner's answer is dropped, nothing is logged; it is simply gone.getNodeSubcluster(...)cannot distinguish "subcluster answered: node not here" (nullNodeInfo) from a real answer. With the owner's entry missing, the loop returns an arbitrary subcluster that does not host the node instead of throwingNotFoundException.Changes:
getNode: merge the parallel results on the calling thread (asinvokeConcurrentalready does) and drop null answers at collection time — this also removes a caught NPE + WARN that the publicgetNode(String)logged for every subcluster that does not host the node.getNodeSubcluster: skip null responses and throwNotFoundExceptionwhen no subcluster hosts the node, soreplaceLabelsOnNode,updateNodeResourceandgetActivitiesfail with 404 semantics instead of being forwarded to a non-owner subcluster.replaceLabelsOnNode: resolve the target subcluster once (it ran the node lookup twice, and the two resolutions could disagree).testGetNodeCollectsAllSubClusterAnswers(36-subcluster fan-out asserting no collected answer is ever lost) and NotFound tests for the three node-scoped calls above.MockDefaultRequestInterceptorRESTis left untouched: itscontains("test")catch-all is load-bearing for other tests, and with the collection race fixed the owner's answer can no longer disappear.Testing: reproduced pre-fix on apache/trunk (full-class runs fail with a random subcluster; an instrumented run showed the owner's entry missing from the collected map, present again 1 ms later in an identical call); with the patch,
TestFederationInterceptorRESTpasses twice consecutively (Tests run: 81, Failures: 0); all 4 new tests fail on the unpatched code (Tests run: 4, Failures: 4) and pass with it.Found while verifying YARN-12025; the flake is pre-existing on trunk-side code and unrelated to that patch.