Skip to content

HDDS-11128. Wait for replication to settle instead of a transient replica count - #11010

Draft
smengcl wants to merge 3 commits into
apache:masterfrom
smengcl:HDDS-11128
Draft

HDDS-11128. Wait for replication to settle instead of a transient replica count#11010
smengcl wants to merge 3 commits into
apache:masterfrom
smengcl:HDDS-11128

Conversation

@smengcl

@smengcl smengcl commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Generated-by: Claude Code (Opus 4.8)

What changes were proposed in this pull request?

TestReconAndAdminContainerCLI#testNodesInDecommissionOrMaintenance intermittently timed out at OzoneTestHelper.waitForReplicaCount after a decommission/maintenance step (HDDS-11128).

Root cause: the test waited on a bare replica-count equality (countReplicas(...) == N). During decommission/maintenance SCM is actively adding and re-evaluating replicas, so the count passes through the expected value transiently, and a fixed-value poll can sample the wrong instant and time out. HDDS-10582 previously only shrank the poll interval (1000ms to 200ms) to narrow that window, so the flake recurred.

This adds OzoneTestHelper.waitForStableReplicaCount, which returns only once replication has quiesced (ReplicationManager reports no pending add/delete ops for the container) AND the count equals N, so the assertion is on a settled state rather than a transient one. It uses the same 30s budget as waitForReplicaCount; no larger timeout is needed, because the call runs right after the DECOMMISSIONED/IN_MAINTENANCE gate, which already requires the new replica to exist, so the settle returns almost immediately. The existing waitForReplicaCount and its other callers are left untouched.

The test stays tagged @Flaky("HDDS-11128") because no wait can prove non-flakiness.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-11128

How was this patch tested?

Existing test, no new coverage added (synchronization-only change to a flaky integration test).

  • mvn -pl :ozone-integration-test test-compile and mvn -pl :ozone-integration-test-recon test-compile: both compile.
  • checkstyle.sh on both changed modules: no violations.

The fix is in the wait predicate (settle on no pending replication ops) rather than the timeout, which addresses the transient-count race directly. As with any flaky fix, a single green run cannot prove non-flakiness, so the @Flaky tag stays.

… waits in TestReconAndAdminContainerCLI

testNodesInDecommissionOrMaintenance intermittently times out at
OzoneTestHelper.waitForReplicaCount while waiting for a decommission-
triggered replica copy (3 -> 4 for the first node, 4 -> 5 for the second)
to be reflected in SCM. The shared waitForReplicaCount helper used a fixed
30s budget for all 14 callers; HDDS-10582 only reduced its poll interval
(1000ms -> 200ms) and kept the 30s total, so under a loaded CI runner the
replica copy is not always observed in time and the test flakes.

Add a 4-arg waitForReplicaCount overload that accepts a timeout, leaving the
existing 3-arg method delegating with the same 30s default (no behavior
change for the other callers). The decommission/maintenance replica-copy
waits in TestReconAndAdminContainerCLI now use a 120s budget, matching the
larger timeouts adopted elsewhere for the same class of replication waits.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 13, 2026 05:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces flakiness in Recon/admin container CLI integration coverage by allowing callers of the shared OzoneTestHelper.waitForReplicaCount helper to specify a larger timeout, and then applying that higher timeout to the decommission/maintenance replica-copy waits that intermittently time out in CI.

Changes:

  • Added a 4-argument waitForReplicaCount(..., timeoutMillis) overload in OzoneTestHelper, keeping the existing 3-arg method as a 30s-default wrapper.
  • Updated TestReconAndAdminContainerCLI#testNodesInDecommissionOrMaintenance to use a 120s timeout when waiting for decommission/maintenance-triggered replica copies to be reflected in SCM.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/OzoneTestHelper.java Introduces a timeout-parameter overload for waitForReplicaCount, preserving the original default behavior.
hadoop-ozone/integration-test-recon/src/test/java/org/apache/hadoop/ozone/recon/TestReconAndAdminContainerCLI.java Uses a larger, named timeout constant for the decommission/maintenance replica-copy waits to reduce test flakiness.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

smengcl and others added 2 commits August 12, 2026 22:58
…ReplicaCount Javadoc link

The happy path returns as soon as the copy lands, so the timeout only
matters on a genuine failure; 120s was more than needed and, because this
@flaky test is rerun on failure in the flaky split, an oversized budget
multiplies wasted CI time on a real break. 60s (double the previous 30s)
gives comfortable headroom for the tail latency while keeping the failing
path bounded.

Also qualify the OzoneTestHelper#waitForReplicaCount(long, int, MiniOzoneCluster)
Javadoc link, which became ambiguous once the timeout overload was added
(flagged by review, avoids doclint resolution warnings).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…lica count

testNodesInDecommissionOrMaintenance waited on a bare replica-count
equality (countReplicas(...) == N) after each decommission/maintenance
step. During decommission SCM is actively adding (and re-evaluating)
replicas, so the count passes through the expected value transiently; a
fixed-value poll can sample the wrong instant and time out. HDDS-10582
only shrank the poll interval (1000ms -> 200ms) to narrow that window, so
the flake recurred (HDDS-11128).

Add OzoneTestHelper.waitForStableReplicaCount, which returns only once
replication has quiesced (ReplicationManager has no pending add/delete ops
for the container) AND the count equals N, so the assertion is on a settled
state rather than a transient one. It uses the same 30s budget as
waitForReplicaCount; the elevated timeout is no longer needed because the
call runs right after the DECOMMISSIONED/IN_MAINTENANCE gate, which already
requires the new replica to exist, so the settle returns almost immediately.
The existing waitForReplicaCount is left untouched for its other callers.
The test remains @flaky("HDDS-11128") because no wait can prove
non-flakiness.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@smengcl smengcl changed the title HDDS-11128. Increase timeout for decommission-triggered replica-count waits in TestReconAndAdminContainerCLI HDDS-11128. Wait for replication to settle instead of a transient replica count Aug 13, 2026
@smengcl
smengcl requested a balanced review from Copilot August 13, 2026 07:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (1)

hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/container/OzoneTestHelper.java:482

  • An empty pending-op list is only a snapshot; it does not mean ReplicationManager has evaluated the latest node/replica state. This test configures RM to scan every 1 second, while this predicate polls every 200 ms, so it can accept an already-present expected count before the next scan schedules an add/delete and reproduce the same transient-state race. ReplicationManager.processAll() is public specifically for tests and synchronized with its monitor thread; run a pass before checking the pending operations so the observed emptiness reflects the current state.
    GenericTestUtils.waitFor(() ->
        replicationManager.getPendingReplicationOps(cid).isEmpty() && countReplicas(containerID, cluster) == count,
        200, 30000);

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants