Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1977,9 +1977,12 @@ BlockRepairResult reconcileChunksPerBlock(KeyValueContainer container, Pipeline
.build();
// Under construction is set here, during BlockInputStream#initialize() it is used to update the block length.
blkInfo.setUnderConstruction(true);
// Always verify peer data before using it to repair this replica, regardless of the client setting.
OzoneClientConfig clientConfig = conf.getObject(OzoneClientConfig.class);
clientConfig.setChecksumVerify(true);
try (BlockInputStream blockInputStream = blockInputStreamFactory.createBlockInputStream(
blkInfo, pipeline, blockToken, dnClient.getXceiverClientManager(),
null, conf.getObject(OzoneClientConfig.class))) {
null, clientConfig)) {
// Initialize the BlockInputStream. Gets the blockData from the peer, sets the block length and
// initializes ChunkInputStream for each chunk.
blockInputStream.initialize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,39 @@ public void testContainerReconciliationWithPeerFailure(FailureLocation failureLo
mockContainerProtocolCalls();
}

@Test
public void testContainerReconciliationVerifiesPeerDataWhenClientChecksumVerifyDisabled() throws Exception {
long containerID = CONTAINER_ID + 2;
for (MockDatanode dn : datanodes) {
dn.addContainerWithBlocks(containerID, 5, false);
dn.scanContainer(containerID);
}
long healthyChecksum = assertUniqueChecksumCount(containerID, datanodes, 1);
MockDatanode laggingNode = datanodes.get(0);
MockDatanode corruptPeer = datanodes.get(1);
MockDatanode healthyPeer = datanodes.get(2);

laggingNode.introduceCorruption(containerID, 1, 0, false);
laggingNode.scanContainer(containerID);
// Corrupt the peer after its last scan so its Merkle tree still advertises healthy data.
corruptPeer.introduceCorruption(containerID, 0, 1, false);

String verifyChecksumKey = "ozone.client.verify.checksum";
laggingNode.conf.setBoolean(verifyChecksumKey, false);
Comment on lines +331 to +332

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
String verifyChecksumKey = "ozone.client.verify.checksum";
laggingNode.conf.setBoolean(verifyChecksumKey, false);
// The datanode should override this configuration value to true and always verify checksums during reconciliation.
String verifyChecksumKey = "ozone.client.verify.checksum";
laggingNode.conf.setBoolean(verifyChecksumKey, false);

try {
laggingNode.reconcileContainerSuccess(dnClient,
Arrays.asList(corruptPeer.getDnDetails(), healthyPeer.getDnDetails()), containerID);
} finally {
laggingNode.conf.unset(verifyChecksumKey);
}

// Reject the corrupt peer's bytes and repair from the healthy peer in the same reconciliation task.
laggingNode.scanContainer(containerID);
assertEquals(healthyChecksum, laggingNode.checkAndGetDataChecksum(containerID));
assertEquals(ContainerProtos.ContainerDataProto.State.CLOSED,
laggingNode.getContainer(containerID).getContainerData().getState());
}

@Test
public void testContainerReconciliationFailureContainerScan()
throws Exception {
Expand Down