dombizita commented on code in PR #10878:
URL: https://github.com/apache/ozone/pull/10878#discussion_r3690923159
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/protocol/ScmBlockLocationProtocolServerSideTranslatorPB.java:
##########
@@ -210,15 +215,64 @@ public AllocateScmBlockResponseProto allocateScmBlock(
" blocks. Requested " + request.getNumBlocks() + " blocks",
SCMException.ResultCodes.FAILED_TO_ALLOCATE_ENOUGH_BLOCKS);
}
+ Map<PipelineID, HddsProtos.Pipeline> pipelineProtoCache = new HashMap<>();
for (AllocatedBlock block : allocatedBlocks) {
+ Pipeline pipeline = block.getPipeline();
+ HddsProtos.Pipeline pipelineProto =
pipelineProtoCache.get(pipeline.getId());
+ if (pipelineProto == null) {
+ try {
+ pipelineProto = withWriteVersion(
+ pipeline.getProtobufMessage(clientVersion, Name.IO_PORTS),
+ computeClusterWriteVersion(pipeline));
+ } catch (NodeNotFoundException e) {
+ throw new IllegalStateException("Datanode not found in NodeManager "
+ + "while computing the write version for pipeline "
+ + pipeline.getId() + " during block allocation. Should not
happen", e);
+ }
+ pipelineProtoCache.put(pipeline.getId(), pipelineProto);
+ }
builder.addBlocks(AllocateBlockResponse.newBuilder()
.setContainerBlockID(block.getBlockID().getProtobuf())
- .setPipeline(block.getPipeline().getProtobufMessage(clientVersion,
Name.IO_PORTS)));
+ .setPipeline(pipelineProto));
}
return builder.build();
}
+ /**
+ * Computes the version clients should use for writes to the given pipeline:
+ * the lowest apparent version among the pipeline's datanodes. During a
rolling
+ * upgrade a pipeline may mix finalized and unfinalized datanodes: an
+ * unfinalized datanode runs the newer software but reports the older
apparent
+ * version until it finalizes. Clients must not enable newer write-path
+ * features until every datanode handling their writes has finalized, so the
+ * minimum apparent version across the pipeline is used.
+ */
+ private int computeClusterWriteVersion(Pipeline pipeline) throws
NodeNotFoundException {
+ return scm.getScmNodeManager()
+ .getLowestApparentVersion(pipeline.getNodes().toArray(new
DatanodeDetails[0]))
+ .serialize();
+ }
+
+ /**
+ * Returns a copy of the pipeline proto with every member's currentVersion
+ * overridden with the computed pipeline write version. The override is
applied
+ * only to the outgoing proto sent to the client; the in-memory pipeline and
+ * its {@link DatanodeDetails} objects (shared with SCM internal state) are
+ * left untouched, so persistence and admin paths keep the real datanode
+ * version. Member order is preserved, keeping {@code memberOrders} and
+ * {@code memberReplicaIndexes} indices valid.
+ */
+ private static HddsProtos.Pipeline withWriteVersion(
Review Comment:
Sounds good, addressed in the latest commit
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]