Skip to content

HDDS-15828. Fix flaky TestDirectoryDeletingServiceWithFSO snapshot cleanup. - #10726

Open
jojochuang wants to merge 2 commits into
apache:masterfrom
jojochuang:HDDS-15828
Open

HDDS-15828. Fix flaky TestDirectoryDeletingServiceWithFSO snapshot cleanup.#10726
jojochuang wants to merge 2 commits into
apache:masterfrom
jojochuang:HDDS-15828

Conversation

@jojochuang

@jojochuang jojochuang commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Previously failed in https://github.com/apache/ozone/actions/runs/29127546564/job/86477855080

Wait for SnapshotDeletingService to purge deleted snapshots before snapshot tests return on the shared mini-cluster, so later tests do not chain off stale global snapshot entries.

What is the link to the Apache JIRA

HDDS-15828. Fix flaky TestDirectoryDeletingServiceWithFSO snapshot cleanup.

How was this patch tested?

flaky-test-check 10x10 all passed: https://github.com/jojochuang/ozone/actions/runs/29134805647

…eanup.

Wait for SnapshotDeletingService to purge deleted snapshots before snapshot
tests return on the shared mini-cluster, so later tests do not chain off stale
global snapshot entries.

Co-authored-by: Cursor <cursoragent@cursor.com>
Change-Id: I57ec596cd5870b68f21ff9d9a89850ea9832f56e
Copilot AI review requested due to automatic review settings July 11, 2026 01:56

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 targets integration-test flakiness in TestDirectoryDeletingServiceWithFSO by ensuring snapshot deletions are fully purged from OM metadata before tests return, avoiding cross-test interference on the shared mini-cluster.

Changes:

  • Replace SnapshotDeletingService shutdown/restart logic with suspend/resume and a dedicated purge-wait helper.
  • Add a waitForSnapshotsPurged(...) helper that drives SnapshotDeletingService and waits for snapshotInfoTable to reach an expected row count.
  • Ensure snapshot purge is awaited after snapshot deletion in another test to avoid leaving global snapshot entries behind.

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

Comment on lines +574 to 577
cluster.getOzoneManager().getKeyManager().getSnapshotDeletingService().suspend();
DirectoryDeletingService dirDeletingService = cluster.getOzoneManager().getKeyManager().getDirDeletingService();
// Suspend KeyDeletingService
dirDeletingService.suspend();
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 13, 2026 18:38

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 1 out of 1 changed files in this pull request and generated 2 comments.

Comment on lines +820 to +832
snapshotDeletingService.resume();
GenericTestUtils.waitFor(() -> {
try {
snapshotDeletingService.runPeriodicalTaskNow();
cluster.getOzoneManager().awaitDoubleBufferFlush();
return cluster.getOzoneManager().getMetadataManager()
.countRowsInTable(snapshotInfoTable) == expectedCount;
} catch (Exception e) {
throw new RuntimeException("Failed to run SnapshotDeletingService purge task", e);
}
}, 1000, 120000);
assertTableRowCount(snapshotInfoTable, expectedCount);
}
Comment on lines +574 to 577
cluster.getOzoneManager().getKeyManager().getSnapshotDeletingService().suspend();
DirectoryDeletingService dirDeletingService = cluster.getOzoneManager().getKeyManager().getDirDeletingService();
// Suspend KeyDeletingService
dirDeletingService.suspend();
Comment on lines +662 to 663
waitForSnapshotsPurged(snapshotInfoTable, initialSnapshotCount);
dirDeletingService.resume();

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.

Thanks for the patch @jojochuang . It might be better to move waitForSnapshotsPurged and dirDeletingService.resume() if suspended to the test teardown method cleanup

// Manual cleanup deletedDirTable for next tests
client.getObjectStore().deleteSnapshot(volumeName, bucketName, "snap1");
cluster.getOzoneManager().awaitDoubleBufferFlush();
waitForSnapshotsPurged(snapshotInfoTable, 0);

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.

Same comment as above. It's better to move waitForSnapshotsPurged and cleanupTables() if suspended to the test teardown method cleanup.


// Manual cleanup deletedDirTable for next tests
client.getObjectStore().deleteSnapshot(volumeName, bucketName, "snap1");
cluster.getOzoneManager().awaitDoubleBufferFlush();

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.

Suggested change
cluster.getOzoneManager().awaitDoubleBufferFlush();

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

This PR has been marked as stale due to 21 days of inactivity. Please comment or remove the stale label to keep it open. Otherwise, it will be automatically closed in 7 days.

@github-actions github-actions Bot added the stale label Aug 8, 2026
@github-actions

Copy link
Copy Markdown

Thank you for your contribution. This PR is being closed due to inactivity. Please contact a maintainer if you would like to reopen it.

@arunsarin85

Copy link
Copy Markdown
Contributor

Hi @SaketaChalamchala @jojochuang

I've addressed all the review comments in a follow-up PR: #11212

Changes made on top of this patch:

  • Moved waitForSnapshotsPurged and dirDeletingService.resume() from the test body into @AfterEach cleanup() using instance tracking fields (snapshotCountAfterTest, pendingResumeDds, needsTableCleanup), so services are always resumed and snapshots always purged even when a test fails mid-way.
  • Moved waitForSnapshotsPurged and cleanupTables() from testDirDeletedTableCleanUpForSnapshot to @AfterEach cleanup() in the same way.
  • Removed the redundant cluster.getOzoneManager().awaitDoubleBufferFlush() before waitForSnapshotsPurged in testDirDeletedTableCleanUpForSnapshot.
  • Fixed mis-indented try/catch braces inside the waitForSnapshotsPurged lambda (checkstyle).
  • Removed the redundant assertTableRowCount call after waitFor in waitForSnapshotsPurged - waitFor already guarantees the condition before returning.

Flaky Test run after the fix : https://github.com/arunsarin85/ozone/actions/runs/33992835360

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.

5 participants