HDDS-14908. Container scanner should check for updates before persisting merkle tree#9987
Draft
errose28 wants to merge 3 commits intoapache:masterfrom
Draft
HDDS-14908. Container scanner should check for updates before persisting merkle tree#9987errose28 wants to merge 3 commits intoapache:masterfrom
errose28 wants to merge 3 commits intoapache:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?
Currently there is no coordination between reconciliation and container scanner by design since they are both long running background processes. As part of this design, there was a known corner case that could cause the checksum to deviate before eventually converging if scanner and reconciliation ran at the same time:
The container scanner builds the merkle tree in memory as it is running, and then flushes it to disk when it finishes scanning the container. If the container is updated (via reconciliation) while the scanner is running, the scanner may not see these updates and as a result persist a stale tree at the end of its scan. A subsequent container scan would then see the fully updated container contents and write the correct tree, restoring the system to a stable state.
This change prevents this case by having the container scanner check the data checksum when it starts, and then again before it persists the tree. If the checksum has changed, the scanner knows its work is now invalid and it must rescan the container to build a new tree.
A maximum number of retries per container is added so that the scanner does not get stuck in a loop on a single container and fail to process others. When the max retries is hit, the scan will be skipped without any affect on the container and its last scan timestamp will not be updated. This will cause the container to be retried first after the whole container set is finished scanning and the next round of scanning begins.
Changes generated by Cursor with review and modifications by me.
What is the link to the Apache JIRA
HDDS-14908
How was this patch tested?
Unit tests added for the following cases:
This change does not apply to the metadata scanner, which does not read or write container data checksums.