-
Notifications
You must be signed in to change notification settings - Fork 587
HDDS-11763. Implement container repair logic within datanodes. #7474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kerneltime
merged 25 commits into
apache:HDDS-10239-container-reconciliation
from
aswinshakil:HDDS-11763-repair
Apr 10, 2025
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
e294940
HDDS-11763. Implement container repair logic within datanodes
aswinshakil 99de480
HDDS-11763. Added test cases and fixed bugs.
aswinshakil f8606fe
HDDS-11763. Fix tests.
aswinshakil 52bde04
Merge branch 'HDDS-10239-container-reconciliation' of https://github.…
aswinshakil 385e8c1
Address partial review comments.
aswinshakil 04aa8a0
Address review comments.
aswinshakil 4f291a0
Merge branch 'HDDS-10239-container-reconciliation' into HDDS-11763-re…
aswinshakil 112762d
Address review.
aswinshakil 07c40e4
Fix tests.
aswinshakil 0350c29
Merge branch 'HDDS-10239-container-reconciliation' of https://github.…
aswinshakil aa34c57
Address Review Comments
aswinshakil 1e5685e
Merge branch 'HDDS-10239-container-reconciliation' of https://github.…
aswinshakil 546bd6f
Add unit test suite
aswinshakil 89a9848
Fix findbugs.
aswinshakil 2b272e7
Fix findbugs.
aswinshakil 7570005
Address review comments.
aswinshakil 47b5fef
Use BlockInputStream to read data.
aswinshakil caffe21
Fix findbugs
aswinshakil 12b9443
Use existing blockData from BlockInputStream
aswinshakil d03e4d9
Use ByteBuffer instead of byte array.
aswinshakil 369b24d
Address review comments.
aswinshakil f062bed
Address review comments.
aswinshakil a5796a1
Update tests and address review comments.
aswinshakil d578f3c
Address review comments.
aswinshakil 130d57a
Address review comments.
aswinshakil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,7 +82,9 @@ public void stop() { | |
| * file remains unchanged. | ||
| * Concurrent writes to the same file are coordinated internally. | ||
| */ | ||
| public void writeContainerDataTree(ContainerData data, ContainerMerkleTreeWriter tree) throws IOException { | ||
| public ContainerProtos.ContainerChecksumInfo writeContainerDataTree(ContainerData data, | ||
| ContainerMerkleTreeWriter tree) | ||
| throws IOException { | ||
| long containerID = data.getContainerID(); | ||
| Lock writeLock = getLock(containerID); | ||
| writeLock.lock(); | ||
|
|
@@ -98,11 +100,13 @@ public void writeContainerDataTree(ContainerData data, ContainerMerkleTreeWriter | |
| checksumInfoBuilder = ContainerProtos.ContainerChecksumInfo.newBuilder(); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Not related to this patch, but we should create a helper function, something like readOrCreate, to handle all the create scenarios for |
||
|
|
||
| checksumInfoBuilder | ||
| ContainerProtos.ContainerChecksumInfo checksumInfo = checksumInfoBuilder | ||
| .setContainerID(containerID) | ||
| .setContainerMerkleTree(captureLatencyNs(metrics.getCreateMerkleTreeLatencyNS(), tree::toProto)); | ||
| write(data, checksumInfoBuilder.build()); | ||
| .setContainerMerkleTree(captureLatencyNs(metrics.getCreateMerkleTreeLatencyNS(), tree::toProto)) | ||
| .build(); | ||
| write(data, checksumInfo); | ||
| LOG.debug("Data merkle tree for container {} updated", containerID); | ||
| return checksumInfo; | ||
| } finally { | ||
| writeLock.unlock(); | ||
| } | ||
|
|
@@ -146,33 +150,32 @@ public void markBlocksAsDeleted(KeyValueContainerData data, Collection<Long> del | |
| } | ||
| } | ||
|
|
||
| public ContainerDiffReport diff(KeyValueContainerData thisContainer, | ||
| /** | ||
| * Compares the checksum info of the container with the peer's checksum info and returns a report of the differences. | ||
| * @param thisChecksumInfo The checksum info of the container on this datanode. | ||
| * @param peerChecksumInfo The checksum info of the container on the peer datanode. | ||
| */ | ||
| public ContainerDiffReport diff(ContainerProtos.ContainerChecksumInfo thisChecksumInfo, | ||
| ContainerProtos.ContainerChecksumInfo peerChecksumInfo) throws | ||
| StorageContainerException { | ||
|
|
||
| ContainerDiffReport report = new ContainerDiffReport(); | ||
| try { | ||
| captureLatencyNs(metrics.getMerkleTreeDiffLatencyNS(), () -> { | ||
| Preconditions.assertNotNull(thisContainer, "Container data is null"); | ||
| Preconditions.assertNotNull(peerChecksumInfo, "Peer checksum info is null"); | ||
| Optional<ContainerProtos.ContainerChecksumInfo> thisContainerChecksumInfo = read(thisContainer); | ||
| if (!thisContainerChecksumInfo.isPresent()) { | ||
| throw new StorageContainerException("The container #" + thisContainer.getContainerID() + | ||
| " doesn't have container checksum", ContainerProtos.Result.IO_EXCEPTION); | ||
| } | ||
|
|
||
| if (thisContainer.getContainerID() != peerChecksumInfo.getContainerID()) { | ||
| throw new StorageContainerException("Container Id does not match for container " | ||
| + thisContainer.getContainerID(), ContainerProtos.Result.CONTAINER_ID_MISMATCH); | ||
| Preconditions.assertNotNull(thisChecksumInfo, "Datanode's checksum info is null."); | ||
| Preconditions.assertNotNull(peerChecksumInfo, "Peer checksum info is null."); | ||
| if (thisChecksumInfo.getContainerID() != peerChecksumInfo.getContainerID()) { | ||
| throw new StorageContainerException("Container ID does not match. Local container ID " | ||
| + thisChecksumInfo.getContainerID() + " , Peer container ID " + peerChecksumInfo.getContainerID(), | ||
| ContainerProtos.Result.CONTAINER_ID_MISMATCH); | ||
| } | ||
|
|
||
| ContainerProtos.ContainerChecksumInfo thisChecksumInfo = thisContainerChecksumInfo.get(); | ||
| compareContainerMerkleTree(thisChecksumInfo, peerChecksumInfo, report); | ||
| }); | ||
| } catch (IOException ex) { | ||
| metrics.incrementMerkleTreeDiffFailures(); | ||
| throw new StorageContainerException("Container Diff failed for container #" + thisContainer.getContainerID(), ex, | ||
| ContainerProtos.Result.IO_EXCEPTION); | ||
| throw new StorageContainerException("Container Diff failed for container #" + thisChecksumInfo.getContainerID(), | ||
| ex, ContainerProtos.Result.IO_EXCEPTION); | ||
| } | ||
|
|
||
| // Update Container Diff metrics based on the diff report. | ||
|
|
@@ -314,7 +317,7 @@ private Lock getLock(long containerID) { | |
| * Callers are not required to hold a lock while calling this since writes are done to a tmp file and atomically | ||
| * swapped into place. | ||
| */ | ||
| private Optional<ContainerProtos.ContainerChecksumInfo> read(ContainerData data) throws IOException { | ||
| public Optional<ContainerProtos.ContainerChecksumInfo> read(ContainerData data) throws IOException { | ||
| long containerID = data.getContainerID(); | ||
| File checksumFile = getContainerChecksumFile(data); | ||
| try { | ||
|
|
@@ -361,6 +364,8 @@ private void write(ContainerData data, ContainerProtos.ContainerChecksumInfo che | |
| throw new IOException("Error occurred when writing container merkle tree for containerID " | ||
| + data.getContainerID(), ex); | ||
| } | ||
| // Set in-memory data checksum. | ||
| data.setDataChecksum(checksumInfo.getContainerMerkleTree().getDataChecksum()); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.