Skip to content
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

HDDS-12007. BlockDataStreamOutput should only send one PutBlock during close. #7645

Merged
merged 3 commits into from
Jan 9, 2025

Conversation

szetszwo
Copy link
Contributor

@szetszwo szetszwo commented Jan 4, 2025

What changes were proposed in this pull request?

Do not do putBlock in link(..). Otherwise,

  • it has two putBlock requests, and
  • it will add the block to db and causing a truncation problem.

What is the link to the Apache JIRA

HDDS-12007

How was this patch tested?

Using existing tests.

@szetszwo szetszwo requested a review from ivandika3 January 5, 2025 19:06
@ivandika3 ivandika3 requested review from xichen01 and symious January 6, 2025 01:23
Copy link
Contributor

@ivandika3 ivandika3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@szetszwo Thanks for the patch.

Should we also revert the changes for HDDS-6500 and HDDS-6137?

@szetszwo
Copy link
Contributor Author

szetszwo commented Jan 6, 2025

@ivandika3 , reverting the code can lead to an incompatible change. Currently, the client sends a PutBlock when closing the stream, and the server reads the PutBlock and processes it. If we revert HDDS-6500 and HDDS-6137, the new client won't send a PutBlock, then the old server will fail since it expects a PutBlock.

The change in this PR is to ignore the PutBlock although the client still sends it.

@ivandika3
Copy link
Contributor

@szetszwo Thanks for the info.

The new client won't send a PutBlock, then the old server will fail since it expects a PutBlock.

Got it, in that case, shall we add some comments about the deprecation so that readers can see that the first putBlock will be ignored by the datanode?

However, eventually the client logic needs to be cleaned up.

@ivandika3
Copy link
Contributor

@szetszwo I have another question. Does sendForward trigger applyTransaction as well? In that case, although ContainerStateMachine#link will ignore it, will ContainerStateMachine#applyTransaction update the DN state?

@@ -689,29 +689,8 @@ public CompletableFuture<?> link(DataStream stream, LogEntryProto entry) {

final KeyValueStreamDataChannel kvStreamDataChannel =
(KeyValueStreamDataChannel) dataChannel;

final ContainerCommandRequestProto request =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we remove KeyValueStreamDataChannel#putBlockRequest, KeyValueStreamDataChannel#buffers and related code, if we remove PutBlock here ?
As I understand it, in order to create the PutBlockReques, we keep a KeyValueStreamDataChannel#buffers in memory, which guarantees that the buffers data will only be written at close. If we remove the PutBlock here, do we not need it anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xichen01 , thanks for reviewing this!

Yes, the putBlockRequest can be removed.

Unfortunately, we still need the buffers since clients still send a putBlockRequest. We need the buffers so the request won't be written to the file as data.

@szetszwo
Copy link
Contributor Author

szetszwo commented Jan 8, 2025

... Does sendForward trigger applyTransaction as well? ...

sendForward is to send the stream header request using the async API.

For Ozone, the request currently is a WriteChunk request but not a PutBlock request. See

ContainerProtos.ContainerCommandRequestProto.Builder builder =
ContainerProtos.ContainerCommandRequestProto.newBuilder()
.setCmdType(ContainerProtos.Type.StreamInit)
.setContainerID(blockID.get().getContainerID())
.setDatanodeUuid(id).setWriteChunk(writeChunkRequest);
if (tokenString != null) {
builder.setEncodedToken(tokenString);
}
ContainerCommandRequestMessage message =
ContainerCommandRequestMessage.toMessage(builder.build(), null);
if (isDatastreamPipelineMode) {
return Preconditions.checkNotNull(xceiverClient.getDataStreamApi())
.stream(message.getContent().asReadOnlyByteBuffer(),
RatisHelper.getRoutingTable(pipeline));
} else {
return Preconditions.checkNotNull(xceiverClient.getDataStreamApi())
.stream(message.getContent().asReadOnlyByteBuffer());
}

In the future, we may combine WriteChunk and PutBlock as in HDDS-9130.

@adoroszlai
Copy link
Contributor

Failure in acceptance (secure) is being fixed in #7668.

Copy link
Contributor

@ivandika3 ivandika3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the info. LGTM +1.

For Ozone, the request currently is a WriteChunk request but not a PutBlock request

Thank you for the info. Checking the code again seems that ContainerStateMachine#applyTransaction is no-op since WriteChunk sent has no data and the WriteStage is COMMIT_DATA. So maybe the sendForward can be skipped in the future.

@adoroszlai adoroszlai merged commit f1f0ec3 into apache:master Jan 9, 2025
42 checks passed
@adoroszlai
Copy link
Contributor

Thanks @szetszwo for the patch, @ivandika3, @xichen01 for the review.

@szetszwo
Copy link
Contributor Author

szetszwo commented Jan 9, 2025

@ivandika3 , @xichen01 , thanks a lot for the review!

@adoroszlai , thanks for helping out the tests and merging this!

@szetszwo
Copy link
Contributor Author

szetszwo commented Jan 9, 2025

... So maybe the sendForward can be skipped in the future.

@ivandika3 , sendForward currently is to add a WritChunk transaction. In the future, you are right that we may be able to skip it or do something else. There are a few options:

  1. RATIS-1936 has changed sendForward to be configurable. We may disable it in Ozone.
  2. It could send both WriteChunk and PutBlock together in sendForward.
  3. Simply send PutBlock in sendForward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants