Skip to content

HDDS-16523. Fix flaky openFileTable assertions in TestHSync - #11281

Merged
chungen0126 merged 2 commits into
apache:masterfrom
rjgoyln:HDDS-16523
Sep 21, 2026
Merged

chungen0126 merged 2 commits into
apache:masterfrom
rjgoyln:HDDS-16523

Conversation

@rjgoyln

@rjgoyln rjgoyln commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

TestHSync#testHSyncOpenKeyCommitAfterExpiry intermittently sees only hsync-key in the open file table, even though it expects both hsync-key and key2.

The assertions read the OM tables through an RDB iterator, which bypasses the table cache. At the same time, OM acknowledges a write as soon as it is queued in the double buffer. As a result, the fs.create(key2) immediately preceding the assertion may not have been persisted yet, while hsync-key already has, because it went through an additional hsync round trip.

  • Wait for the double buffer to flush before reading the table in testHSyncOpenKeyCommitAfterExpiry.
  • Apply the same fix to testHSyncOpenKeyDeletionWhileDeleteDirectory, whose assertion after os.hsync() has the same race.

This file already waits for the double buffer before seven other table reads, so these changes preserve the strength of the assertions rather than weakening them.

What is the link to the Apache JIRA

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

How was this patch tested?

Both test methods pass locally, with checkstyle and PMD clean for the module.

The race was also made deterministic to confirm the fix addresses it: pausing the double buffer before fs.create(key2) and unpausing it from another thread three seconds later. Without this patch the assertion then fails exactly as reported in the JIRA.

Expecting ArrayList:
  ["hsync-key"]
to contain:
  ["hsync-key", "key2"]
but could not find the following element(s):
  ["key2"]

The same stalled run passes with the patch. That instrumentation is not part of the change.

Generated-by: Claude Code (Opus 5)

…fterExpiry

The assertions read the OM tables through an RDB iterator, which bypasses the
table cache, while OM acknowledges a write as soon as the double buffer queues
the response. A key created by the immediately preceding call can therefore
still be invisible when the assertion runs.
Copilot AI lite review requested due to automatic review settings September 20, 2026 06:22

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.

Copilot review overview

🟢 Approval recommended

No unresolved issues; the changes address the flaky assertions while preserving their strictness.

Review effort: Lite
Findings: None

What changed in this PR

This pull request fixes flaky TestHSync assertions by waiting for OM double-buffer persistence before reading open-file tables.

Changes:

  • Added flush waits in both affected tests.
  • Preserved strict table-content assertions.
File Description
hadoop-ozone/​integration-test/​src/​test/​java/​org/​apache/​hadoop/​fs/​ozone/​TestHSync.java Synchronizes assertions with OM persistence.

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

@rjgoyln
rjgoyln marked this pull request as ready for review September 20, 2026 06:42
@adoroszlai
adoroszlai requested a review from smengcl September 20, 2026 07:39
@Russole
Russole requested review from Russole and removed request for smengcl September 20, 2026 07:39
@chungen0126

Copy link
Copy Markdown
Contributor

Thanks @rjgoyln for working on this! Could you please use the GitHub Actions flaky-test-check workflow to verify this change?

@chungen0126 chungen0126 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.

+1 LGTM

@peterxcli
peterxcli requested a review from ivandika3 September 21, 2026 12:49

@peterxcli peterxcli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

@peterxcli peterxcli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@ivandika3 just FYI

The assertion became effective in HDDS-16084 (commit a9c9caf), which replaced the no-op assertThat(2 == getOpenKeyInfo(...).size()) with a real AssertJ assertion on key
names. The race it exposes, however, predates that change.

@rjgoyln

rjgoyln commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

@chungen0126 Thanks for the review!

Done. Ran flaky-test-check on both methods with 10 splits × 10 iterations — all green.

Also verified the fix deterministically: delaying the OM double buffer around fs.create(key2) reproduces the reported failure without the patch and passes with it.

https://github.com/rjgoyln/ozone/actions/runs/35602763721

@chungen0126
chungen0126 merged commit d18115d into apache:master Sep 21, 2026
55 of 58 checks passed
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.

4 participants