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-10821. Ensure ozone write all the buffer content to FileChannel. #6652

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

duongkame
Copy link
Contributor

What changes were proposed in this pull request?

Ozone should expect FileChannel.write doesn't fully write the entire buffer and not crash the pipeline one that happens.

See HDDS-10821.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-10821

How was this patch tested?

CI.

Copy link
Contributor

@adoroszlai adoroszlai left a comment

Choose a reason for hiding this comment

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

Thanks @duongkame for the patch.

Comment on lines 147 to 150
* Write all the contents of the buffer from the current position to the limit
* to {@code channel}.
*/
void writeFully(GatheringByteChannel channel) throws IOException;
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like to suggest fixing writeTo instead of adding this new method to the interface.

  1. In what case may we want to use the existing method? With this fix, writeTo becomes unused in production.

  2. TestChunkBuffer.assertWrite tests writeTo and expects it to write all data. However, it only works because the channels it uses, unlike FileChannel, write fully. This can be verified by randomly adjusting limit for the buffer in MockGatheringChannel.write(ByteBuffer), i.e. simulating incomplete writes. On the other hand, writeFully is not covered by unit tests.

  3. We can avoid the changes in ChunkUtils, most of which is due to writeFully not returning the number of bytes written.

Copy link
Contributor

Choose a reason for hiding this comment

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

@duongkame you can pick adoroszlai@daee756, which implements the suggested change

Comment on lines 148 to 149
throws IOException
{
Copy link
Contributor

Choose a reason for hiding this comment

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

hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/utils/BufferUtils.java
 149: '{' at column 3 should be on the previous line.

Comment on lines 152 to 153
if (n <= 0)
throw new IllegalStateException("no bytes written");
Copy link
Contributor

Choose a reason for hiding this comment

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

hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/common/utils/BufferUtils.java
 152: 'if' construct must use '{}'s.

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