Skip to content

HDDS-15822. Fix flaky TestStorageVolumeChecker#testNumScansSkipped#10720

Merged
smengcl merged 1 commit into
apache:masterfrom
smengcl:HDDS-15822
Jul 11, 2026
Merged

HDDS-15822. Fix flaky TestStorageVolumeChecker#testNumScansSkipped#10720
smengcl merged 1 commit into
apache:masterfrom
smengcl:HDDS-15822

Conversation

@smengcl

@smengcl smengcl commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Generated-by: Claude Code (Opus 4.8)

What changes were proposed in this pull request?

TestStorageVolumeChecker#testNumScansSkipped fails intermittently with expected: <1> but was: <2> (seen in upstream CI on 2026-07-09).

The test uses the real ThrottledAsyncChecker, which runs volume checks on a background executor and wraps them with Futures.withTimeout. The callback that records each check's completedAt runs on those executor threads. On a busy JVM this races with the test's timer.advance(), so a check's completedAt is occasionally recorded against a later timer value. On the third checkAllVolumes call the affected volume then looks like it is still within minMsBetweenChecks and is skipped, which inflates numScansSkipped from 1 to 2.

This PR makes the check synchronous for this test by installing a ThrottledAsyncChecker backed by a direct executor service, and by setting diskCheckTimeout to zero so no Futures.withTimeout wrapper is created. completedChecks is then fully populated before checkAllVolumes returns, which removes the race. The throttling gap (getDiskCheckMinGap) is unchanged, so the test still verifies skip counting, and the asynchronous per volume timeout path stays covered by the dedicated test added in HDDS-14871. The change is limited to the test.

What is the link to the Apache JIRA

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

How was this patch tested?

Ran testNumScansSkipped 100 times locally with 0 failures. Ran the full TestStorageVolumeChecker class (20 tests) multiple times with no failures. Checkstyle clean.

Use a synchronous direct-executor ThrottledAsyncChecker and diskCheckTimeout=0
so completedChecks is fully populated before checkAllVolumes returns, removing
the race with timer.advance() that intermittently inflated numScansSkipped.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 10, 2026 20:19

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 fixes a flake in TestStorageVolumeChecker#testNumScansSkipped by removing a timing race between asynchronous volume-check completion callbacks and the test’s FakeTimer.advance() calls. It does this by making the delegate checker effectively synchronous for this specific test case, while keeping the throttling behavior being asserted.

Changes:

  • Configure diskCheckTimeout=0 for the test’s StorageVolumeChecker instance.
  • Replace the default async delegate with a ThrottledAsyncChecker backed by a direct executor to ensure completedChecks is updated before checkAllVolumes returns.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@smengcl smengcl marked this pull request as ready for review July 11, 2026 00:05
@smengcl smengcl merged commit 78cb493 into apache:master Jul 11, 2026
44 checks passed
@smengcl smengcl deleted the HDDS-15822 branch July 11, 2026 01:18
@smengcl

smengcl commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @jojochuang for reviewing this.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants