You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "pan3793 (via GitHub)" <gi...@apache.org> on 2026/06/05 08:36:46 UTC

[PR] HADOOP-19820. Fix flaky TestBalancerLongRunningTasks [hadoop]

pan3793 opened a new pull request, #8534:
URL: https://github.com/apache/hadoop/pull/8534

   <!--
     Thanks for sending a pull request!
       1. If this is your first time, please read our contributor guidelines: https://cwiki.apache.org/confluence/display/HADOOP/How+To+Contribute
       2. Make sure your PR title starts with JIRA issue id, e.g., 'HADOOP-17799. Your PR title ...'.
   -->
   
   ### Description of PR
   
   Fix flaky tests like https://github.com/kokonguyen191/hadoop/actions/runs/26836456695/job/79134194743
   ```
   [INFO] Results:
   [INFO] 
   Error:  Errors: 
   Error:  org.apache.hadoop.hdfs.server.balancer.TestBalancerLongRunningTasks.testBalancerMetricsDuplicate
   Error:    Run 1: TestBalancerLongRunningTasks.testBalancerMetricsDuplicate:835 expected: <0> but was: <-3>
   Error:    Run 2: TestBalancerLongRunningTasks.testBalancerMetricsDuplicate:797 » Metrics Metrics source RetryCache.NameNodeRetryCache already exists!
   Error:    Run 3: TestBalancerLongRunningTasks.testBalancerMetricsDuplicate:797 » Metrics Metrics source RetryCache.NameNodeRetryCache already exists!
   ...
   [INFO] 
   Error:  Tests run: 1219, Failures: 0, Errors: 6, Skipped: 0
   ```
   
   Two changes in `TestBalancerLongRunningTasks`:
   
   1. `@AfterEach shutdown()` — Added `DefaultMetricsSystem.shutdown()` to reset the metrics singleton after each test, preventing stale `RetryCache.NameNodeRetryCache` registrations from carrying over between tests in the same JVM.
   
   2. `testBalancerMetricsDuplicate()` — Wrapped the `setMiniClusterMode(false)` block in `try-finally` so `setMiniClusterMode(true)` is always restored. Previously, if the assertion on line 836 failed, the restoration was skipped, poisoning all subsequent test retries.
   
   ### How was this patch tested?
   
   Pass GHA.
   
   ### For code changes:
   
   - [x] Does the title or this PR starts with the corresponding JIRA issue id (e.g. 'HADOOP-17799. Your PR title ...')?
   - [ ] Object storage: have the integration tests been executed and the endpoint declared according to the connector-specific documentation?
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`, `NOTICE-binary` files?
   
   ### AI Tooling
   
   Assisted-by: OpenCode (Mimo-V2.5-Pro)


-- 
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: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org


Re: [PR] HADOOP-19911. Fix flaky TestBalancerLongRunningTasks [hadoop]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on PR #8534:
URL: https://github.com/apache/hadoop/pull/8534#issuecomment-4718364164

   thanks, merged to trunk/branch-3.5


-- 
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: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org


Re: [PR] HADOOP-19820. Fix flaky TestBalancerLongRunningTasks [hadoop]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #8534:
URL: https://github.com/apache/hadoop/pull/8534#discussion_r3366753879


##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancerLongRunningTasks.java:
##########
@@ -823,17 +824,20 @@ public void testBalancerMetricsDuplicate() throws Exception {
 
       // Throw an error when we double-initialize BalancerMetrics
       DefaultMetricsSystem.setMiniClusterMode(false);
-      MetricsSystem instance = DefaultMetricsSystem.instance();
-      // Avoid the impact of cluster metric, remove cluster JvmMetrics
-      instance.unregisterSource("JvmMetrics");
-
-      final BalancerParameters balancerParameters = Balancer.Cli.parse(new String[] {
-          "-policy", BalancingPolicy.Node.INSTANCE.getName(),
-          "-threshold", "10",
-      });
-      int r = Balancer.run(namenodes, nsIds, balancerParameters, conf);
-      assertEquals(ExitStatus.SUCCESS.getExitCode(), r);
-      DefaultMetricsSystem.setMiniClusterMode(true);
+      try {
+        MetricsSystem instance = DefaultMetricsSystem.instance();
+        // Avoid the impact of cluster metric, remove cluster JvmMetrics

Review Comment:
   The test forces `setMiniClusterMode(false)` but always restores to `true`, which can change global state if the previous value wasn’t `true` (and differs from the pattern used elsewhere in the codebase). Capture the prior value via `DefaultMetricsSystem.inMiniClusterMode()` and restore that in the `finally`.



##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancerLongRunningTasks.java:
##########
@@ -110,6 +110,7 @@ public void shutdown() throws Exception {
       cluster.shutdown();
       cluster = null;
     }
+    DefaultMetricsSystem.shutdown();

Review Comment:
   `DefaultMetricsSystem.shutdown()` won’t run if `cluster.shutdown()` throws, which can leave the metrics singleton in a dirty state (the flake you’re addressing) and potentially affect subsequent tests. Wrap the cluster shutdown in a `try/finally` so metrics are always reset, and null out `cluster` in the `finally` to avoid reuse after a failed shutdown.



-- 
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: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org


Re: [PR] HADOOP-19911. Fix flaky TestBalancerLongRunningTasks [hadoop]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 merged PR #8534:
URL: https://github.com/apache/hadoop/pull/8534


-- 
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: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org


Re: [PR] HADOOP-19820. Fix flaky TestBalancerLongRunningTasks [hadoop]

Posted by "hadoop-yetus (via GitHub)" <gi...@apache.org>.
hadoop-yetus commented on PR #8534:
URL: https://github.com/apache/hadoop/pull/8534#issuecomment-4631779807

   :broken_heart: **-1 overall**
   
   
   
   
   
   
   | Vote | Subsystem | Runtime |  Logfile | Comment |
   |:----:|----------:|--------:|:--------:|:-------:|
   | +0 :ok: |  reexec  |   0m 20s |  |  Docker mode activated.  |
   |||| _ Prechecks _ |
   | +1 :green_heart: |  dupname  |   0m  0s |  |  No case conflicting files found.  |
   | +0 :ok: |  codespell  |   0m  1s |  |  codespell was not available.  |
   | +0 :ok: |  detsecrets  |   0m  1s |  |  detect-secrets was not available.  |
   | +1 :green_heart: |  @author  |   0m  0s |  |  The patch does not contain any @author tags.  |
   | +1 :green_heart: |  test4tests  |   0m  0s |  |  The patch appears to include 1 new or modified test files.  |
   |||| _ trunk Compile Tests _ |
   | +1 :green_heart: |  mvninstall  |  28m 36s |  |  trunk passed  |
   | +1 :green_heart: |  compile  |   1m  3s |  |  trunk passed with JDK Ubuntu-21.0.11+10-1-24.04.2-Ubuntu  |
   | +1 :green_heart: |  compile  |   1m  7s |  |  trunk passed with JDK Ubuntu-17.0.19+10-1-24.04.2-Ubuntu  |
   | +1 :green_heart: |  checkstyle  |   0m 59s |  |  trunk passed  |
   | +1 :green_heart: |  mvnsite  |   1m  0s |  |  trunk passed  |
   | +1 :green_heart: |  javadoc  |   0m 49s |  |  trunk passed with JDK Ubuntu-21.0.11+10-1-24.04.2-Ubuntu  |
   | +1 :green_heart: |  javadoc  |   0m 51s |  |  trunk passed with JDK Ubuntu-17.0.19+10-1-24.04.2-Ubuntu  |
   | +1 :green_heart: |  spotbugs  |   2m 24s |  |  trunk passed  |
   | +1 :green_heart: |  shadedclient  |  18m 18s |  |  branch has no errors when building and testing our client artifacts.  |
   |||| _ Patch Compile Tests _ |
   | +1 :green_heart: |  mvninstall  |   0m 51s |  |  the patch passed  |
   | +1 :green_heart: |  compile  |   0m 44s |  |  the patch passed with JDK Ubuntu-21.0.11+10-1-24.04.2-Ubuntu  |
   | +1 :green_heart: |  javac  |   0m 44s |  |  the patch passed  |
   | +1 :green_heart: |  compile  |   0m 48s |  |  the patch passed with JDK Ubuntu-17.0.19+10-1-24.04.2-Ubuntu  |
   | +1 :green_heart: |  javac  |   0m 48s |  |  the patch passed  |
   | +1 :green_heart: |  blanks  |   0m  0s |  |  The patch has no blanks issues.  |
   | +1 :green_heart: |  checkstyle  |   0m 49s |  |  the patch passed  |
   | +1 :green_heart: |  mvnsite  |   0m 47s |  |  the patch passed  |
   | +1 :green_heart: |  javadoc  |   0m 38s |  |  the patch passed with JDK Ubuntu-21.0.11+10-1-24.04.2-Ubuntu  |
   | +1 :green_heart: |  javadoc  |   0m 39s |  |  the patch passed with JDK Ubuntu-17.0.19+10-1-24.04.2-Ubuntu  |
   | +1 :green_heart: |  spotbugs  |   2m 19s |  |  the patch passed  |
   | +1 :green_heart: |  shadedclient  |  18m 15s |  |  patch has no errors when building and testing our client artifacts.  |
   |||| _ Other Tests _ |
   | -1 :x: |  unit  | 185m 30s | [/patch-unit-hadoop-hdfs-project_hadoop-hdfs.txt](https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8534/1/artifact/out/patch-unit-hadoop-hdfs-project_hadoop-hdfs.txt) |  hadoop-hdfs in the patch passed.  |
   | +1 :green_heart: |  asflicense  |   0m 31s |  |  The patch does not generate ASF License warnings.  |
   |  |   | 266m 24s |  |  |
   
   
   | Reason | Tests |
   |-------:|:------|
   | Failed junit tests | hadoop.hdfs.server.balancer.TestBalancerWithHANameNodes |
   
   
   | Subsystem | Report/Notes |
   |----------:|:-------------|
   | Docker | ClientAPI=1.54 ServerAPI=1.54 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8534/1/artifact/out/Dockerfile |
   | GITHUB PR | https://github.com/apache/hadoop/pull/8534 |
   | Optional Tests | dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets |
   | uname | Linux 67d55378ffd9 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux |
   | Build tool | maven |
   | Personality | dev-support/bin/hadoop.sh |
   | git revision | trunk / 78b57f63ecc1f04a2f4bd0b8fae36e3eeee34274 |
   | Default Java | Ubuntu-17.0.19+10-1-24.04.2-Ubuntu |
   | Multi-JDK versions | /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.11+10-1-24.04.2-Ubuntu /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.19+10-1-24.04.2-Ubuntu |
   |  Test Results | https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8534/1/testReport/ |
   | Max. process+thread count | 3759 (vs. ulimit of 10000) |
   | modules | C: hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project/hadoop-hdfs |
   | Console output | https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8534/1/console |
   | versions | git=2.43.0 maven=3.9.15 spotbugs=4.9.7 |
   | Powered by | Apache Yetus 0.14.1 https://yetus.apache.org |
   
   
   This message was automatically generated.
   
   


-- 
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: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org


Re: [PR] HADOOP-19820. Fix flaky TestBalancerLongRunningTasks [hadoop]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #8534:
URL: https://github.com/apache/hadoop/pull/8534#discussion_r3370637762


##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancerLongRunningTasks.java:
##########
@@ -823,17 +824,20 @@ public void testBalancerMetricsDuplicate() throws Exception {
 
       // Throw an error when we double-initialize BalancerMetrics
       DefaultMetricsSystem.setMiniClusterMode(false);
-      MetricsSystem instance = DefaultMetricsSystem.instance();
-      // Avoid the impact of cluster metric, remove cluster JvmMetrics
-      instance.unregisterSource("JvmMetrics");
-
-      final BalancerParameters balancerParameters = Balancer.Cli.parse(new String[] {
-          "-policy", BalancingPolicy.Node.INSTANCE.getName(),
-          "-threshold", "10",
-      });
-      int r = Balancer.run(namenodes, nsIds, balancerParameters, conf);
-      assertEquals(ExitStatus.SUCCESS.getExitCode(), r);
-      DefaultMetricsSystem.setMiniClusterMode(true);
+      try {
+        MetricsSystem instance = DefaultMetricsSystem.instance();
+        // Avoid the impact of cluster metric, remove cluster JvmMetrics

Review Comment:
   changed to memorize the prior state and restore it in the `finally` block



-- 
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: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org


Re: [PR] HADOOP-19820. Fix flaky TestBalancerLongRunningTasks [hadoop]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #8534:
URL: https://github.com/apache/hadoop/pull/8534#discussion_r3370636202


##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancerLongRunningTasks.java:
##########
@@ -110,6 +110,7 @@ public void shutdown() throws Exception {
       cluster.shutdown();
       cluster = null;
     }
+    DefaultMetricsSystem.shutdown();

Review Comment:
   make sense, adopted



-- 
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: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org


Re: [PR] HADOOP-19911. Fix flaky TestBalancerLongRunningTasks [hadoop]

Posted by "slfan1989 (via GitHub)" <gi...@apache.org>.
slfan1989 commented on PR #8534:
URL: https://github.com/apache/hadoop/pull/8534#issuecomment-4714368867

   LGTM. @zhtttylz Could you please help review this PR? Thank you very much!


-- 
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: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org