Skip to content

Commit ed1a41b

Browse files
swamirishipony.chen
authored andcommitted
HDDS-11132. Revert client version bump done as part of HDDS-10983 (apache#7348)
(cherry picked from commit e7bf154)
1 parent 07cb23f commit ed1a41b

5 files changed

Lines changed: 8 additions & 26 deletions

File tree

hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/ClientVersion.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ public enum ClientVersion implements ComponentVersion {
4242
"This client version has support for Object Store and File " +
4343
"System Optimized Bucket Layouts."),
4444

45-
EC_REPLICA_INDEX_REQUIRED_IN_BLOCK_REQUEST(4,
46-
"This client version enforces replica index is set for fixing read corruption that could occur when " +
47-
"replicaIndex parameter is not validated before EC block reads."),
48-
4945
FUTURE_VERSION(-1, "Used internally when the server side is older and an"
5046
+ " unknown client version has arrived from the client.");
5147

hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115
import static org.apache.hadoop.hdds.scm.utils.ClientCommandsUtils.getReadChunkVersion;
116116
import static org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos
117117
.ContainerDataProto.State.RECOVERING;
118-
import static org.apache.hadoop.ozone.ClientVersion.EC_REPLICA_INDEX_REQUIRED_IN_BLOCK_REQUEST;
119118
import static org.apache.hadoop.ozone.container.common.interfaces.Container.ScanResult;
120119

121120
import org.apache.ratis.statemachine.StateMachine;
@@ -563,15 +562,6 @@ ContainerCommandResponseProto handlePutBlock(
563562
return putBlockResponseSuccess(request, blockDataProto);
564563
}
565564

566-
/**
567-
* Checks if a replicaIndex needs to be checked based on the client version for a request.
568-
* @param request ContainerCommandRequest object.
569-
* @return true if the validation is required for the client version else false.
570-
*/
571-
private boolean replicaIndexCheckRequired(ContainerCommandRequestProto request) {
572-
return request.hasVersion() && request.getVersion() >= EC_REPLICA_INDEX_REQUIRED_IN_BLOCK_REQUEST.toProtoValue();
573-
}
574-
575565
/**
576566
* Handle Get Block operation. Calls BlockManager to process the request.
577567
*/
@@ -590,9 +580,7 @@ ContainerCommandResponseProto handleGetBlock(
590580
try {
591581
BlockID blockID = BlockID.getFromProtobuf(
592582
request.getGetBlock().getBlockID());
593-
if (replicaIndexCheckRequired(request)) {
594-
BlockUtils.verifyReplicaIdx(kvContainer, blockID);
595-
}
583+
BlockUtils.verifyReplicaIdx(kvContainer, blockID);
596584
responseData = blockManager.getBlock(kvContainer, blockID).getProtoBufMessage();
597585
final long numBytes = responseData.getSerializedSize();
598586
metrics.incContainerBytesStats(Type.GetBlock, numBytes);
@@ -709,9 +697,7 @@ ContainerCommandResponseProto handleReadChunk(
709697
ChunkInfo chunkInfo = ChunkInfo.getFromProtoBuf(request.getReadChunk()
710698
.getChunkData());
711699
Preconditions.checkNotNull(chunkInfo);
712-
if (replicaIndexCheckRequired(request)) {
713-
BlockUtils.verifyReplicaIdx(kvContainer, blockID);
714-
}
700+
BlockUtils.verifyReplicaIdx(kvContainer, blockID);
715701
BlockUtils.verifyBCSId(kvContainer, blockID);
716702

717703
if (dispatcherContext == null) {

hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/helpers/BlockUtils.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ public static void verifyBCSId(Container container, BlockID blockID)
248248
public static void verifyReplicaIdx(Container container, BlockID blockID)
249249
throws IOException {
250250
Integer containerReplicaIndex = container.getContainerData().getReplicaIndex();
251-
if (containerReplicaIndex > 0 && !containerReplicaIndex.equals(blockID.getReplicaIndex())) {
251+
Integer blockReplicaIndex = blockID.getReplicaIndex();
252+
if (containerReplicaIndex > 0 && blockReplicaIndex != null && blockReplicaIndex != 0 &&
253+
!containerReplicaIndex.equals(blockReplicaIndex)) {
252254
throw new StorageContainerException(
253255
"Unable to find the Container with replicaIdx " + blockID.getReplicaIndex() + ". Container "
254256
+ container.getContainerData().getContainerID() + " replicaIdx is "

hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/keyvalue/TestKeyValueHandlerWithUnhealthyContainer.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ public void testGetBlockWithReplicaIndexMismatch(ClientVersion clientVersion, in
115115
handler.handleGetBlock(
116116
getDummyCommandRequestProto(clientVersion, ContainerProtos.Type.GetBlock, rid),
117117
container);
118-
assertEquals((replicaIndex > 0 && rid != replicaIndex && clientVersion.toProtoValue() >=
119-
ClientVersion.EC_REPLICA_INDEX_REQUIRED_IN_BLOCK_REQUEST.toProtoValue()) ?
118+
assertEquals((replicaIndex > 0 && rid != 0 && rid != replicaIndex) ?
120119
ContainerProtos.Result.CONTAINER_NOT_FOUND : UNKNOWN_BCSID,
121120
response.getResult());
122121
}
@@ -158,8 +157,7 @@ public void testReadChunkWithReplicaIndexMismatch(ClientVersion clientVersion, i
158157
ContainerProtos.ContainerCommandResponseProto response =
159158
handler.handleReadChunk(getDummyCommandRequestProto(clientVersion, ContainerProtos.Type.ReadChunk, rid),
160159
container, null);
161-
assertEquals((replicaIndex > 0 && rid != replicaIndex &&
162-
clientVersion.toProtoValue() >= ClientVersion.EC_REPLICA_INDEX_REQUIRED_IN_BLOCK_REQUEST.toProtoValue()) ?
160+
assertEquals((replicaIndex > 0 && rid != 0 && rid != replicaIndex) ?
163161
ContainerProtos.Result.CONTAINER_NOT_FOUND : UNKNOWN_BCSID,
164162
response.getResult());
165163
}

hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/storage/TestContainerCommandsEC.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ public void testCreateRecoveryContainer() throws Exception {
460460
int replicaIndex = 4;
461461
XceiverClientSpi dnClient = xceiverClientManager.acquireClient(
462462
createSingleNodePipeline(newPipeline, newPipeline.getNodes().get(0),
463-
replicaIndex));
463+
2));
464464
try {
465465
// To create the actual situation, container would have been in closed
466466
// state at SCM.

0 commit comments

Comments
 (0)