HDDS-13841. Namespace summary API gives wrong count of directories and keys. #9207
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR change is to fix the issue where number of keys showing wrong value when creating dirs and keys inside a FSO bucket using
ozone fs -mkdiroption.As per initial analysis, below is the cause of this issue:
The issue was in the
handlePutKeyEventmethod inNSSummaryTaskDbEventHandler.javaWhen a file is created, if its parent directory's NSSummary doesn't exist in the in-memory map or database, thecode creates a new NSSummary with default values, including parentId = 0. This breaks the propagation chain, preventing key counts from being propagated to ancestor directories and the bucket.
This can occur when:
1. Directory creation events and file creation events are processed in different batches
2. Directory NSSummaries haven't been persisted to the DB when file events arrive
3. This can happen when directory creation events and file creation events are processed in different batches. Could be because of recent optimizations done at OM for batch processing.
When the propagation chain is broken (parentId = 0), the propagateSizeUpwards method stops propagating counts upward, resulting in incorrect total key counts at the bucket level.
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-13841
How was this patch tested?
Patch is tested using existing junit and integration tests and manually using local docker cluster.
