Skip to content

HDDS-15038. Clean up chunks before metadata for failed container import#10199

Open
devmadhuu wants to merge 1 commit intoapache:masterfrom
devmadhuu:HDDS-15038
Open

HDDS-15038. Clean up chunks before metadata for failed container import#10199
devmadhuu wants to merge 1 commit intoapache:masterfrom
devmadhuu:HDDS-15038

Conversation

@devmadhuu
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This PR handles failed container import cleanup on the DataNode. KeyValueContainer.cleanupFailedImport() now deletes the chunks/ directory before deleting the metadata/ directory. If cleanup is interrupted or partially fails between child-
directory deletions, the remaining on-disk state now preferentially preserves metadata instead of leaving a harder-to-diagnose chunks/-only residual directory.

A focused test was added to inject an import cleanup failure at metadata deletion and verify that chunks/ has already been removed while metadata/ remains.

What is the link to the Apache JIRA

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

How was this patch tested?

Added TestKeyValueContainer#testFailedImportCleanupDeletesChunksBeforeMetadata

@devmadhuu devmadhuu requested review from ChenSammi and errose28 May 6, 2026 07:44
@devmadhuu devmadhuu marked this pull request as ready for review May 6, 2026 09:53
@adoroszlai adoroszlai changed the title HDDS-15038. Change cleanupFailedImport() to delete chunks before metadata to avoid chunks-only residual state. HDDS-15038. Clean up chunks before metadata for failed container import May 6, 2026
if (containerData.hasSchema(OzoneConsts.SCHEMA_V3)) {
BlockUtils.removeContainerFromDB(containerData, config);
}
FileUtils.deleteDirectory(new File(containerData.getMetadataPath()));
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.

@devmadhuu , we can first move the container directory to tmp, and then delete it. If any deletion in between failed, the residual will not impact normal flow, and it will be deleted on DN restart or next time this container is downloaded for import.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @ChenSammi , this is better approach. I updated the patch to move the container directory to the deleted-container tmp area first, then delete it from there.

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.

2 participants