Skip to content

Conversation

@sadanand48
Copy link
Contributor

What changes were proposed in this pull request?

Handle client write retries on exception

What is the link to the Apache JIRA

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

How was this patch tested?

Unit tests.

@arp7 arp7 requested review from captainzmc and szetszwo October 2, 2021 15:54
Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

@sadanand48 , thanks a lot for working on this.

In Streaming, we should not have a buffer pool since we won't reuse buffers. We probably need a new class for the bufferList. Then, we can put all the related logic inside the new class.

BTW, please add some tests. Thanks.

@sadanand48
Copy link
Contributor Author

Thanks @szetszwo and @bshashikant for the review. Yes I will be adding more tests. Also , we are not using BufferPool
here instead maintaining a list that contains a reference to the buffers that are passed by the client. Currently we maintain a commitIndexMap which contains list of buffers for a particular commitIndex and the buffers are discarded from the list during stream watchForCommit.

Currently on retry , we discard the previous buffers in the bufferList and start from 0 regardless of whether all the nodes have upto certain data. In a follow up task , I will maintain stream ack like you suggested and only retry writing the data that is not present in all nodes.

@sadanand48 sadanand48 marked this pull request as ready for review October 13, 2021 08:37
Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

A major problem is the following line in StreamCommitWatcher.releaseBuffers(..)

 bufferPool.remove(byteBuffer);

since it is super expensive. We need some way to avoid it. Thanks.

@szetszwo
Copy link
Contributor

int j = 0;
for(; j < buffers.size(); j++) {
  if (byteBuffer == buffers.get(i)) {
    break;
  }
}
buffers.remove(j);

@szetszwo
Copy link
Contributor

Actually, using == to compare ByteBuffer may not work since there are duplicated buffers. We need to create a new class. Let me think about it.

@szetszwo
Copy link
Contributor

public class StreamBuffer {
  private final ByteBuffer buffer;

  public StreamBuffer(ByteBuffer buffer) {
    this.buffer = buffer.asReadOnlyBuffer();
  }

  public StreamBuffer(ByteBuffer buffer, int offset, int length) {
    this((ByteBuffer) buffer.asReadOnlyBuffer().position(offset).limit(offset + length));
  }


  public ByteBuffer duplicate() {
    return buffer.duplicate();
  }

  public int length() {
    return buffer.limit() - buffer.position();
  }
}

We may create a new StreamBuffer as shown above. Then, we can use ==. Tried it with the current change. It seems working; please test it: https://issues.apache.org/jira/secure/attachment/13035081/StreamBuffer.patch

Sadanand Shenoy added 5 commits October 20, 2021 10:12
(cherry picked from commit 2dc98b9839f22625ec78f3905b941cb444c82024)
(cherry picked from commit cb50698b13fb2c53a10a9d44b607d19e3806a9d0)
(cherry picked from commit 50cacaee7e829f693648c6701e33d7f912a7eced)
(cherry picked from commit 22fe01e98d7cfceefce36d27f4b5941478c7a3b3)
@sadanand48
Copy link
Contributor Author

sadanand48 commented Oct 20, 2021

Thanks @szetszwo for the review comments. I have updated the patch. Will add more tests in a separate jira

@sadanand48
Copy link
Contributor Author

We may create a new StreamBuffer as shown above. Then, we can use ==. Tried it with the current change. It seems working; please test it: https://issues.apache.org/jira/secure/attachment/13035081/StreamBuffer.patch

We are not comparing duplicated buffers here, since the same StreamBuffer object is present in bufferList and the commitInfoMap so we can use equals() and since its on the new StreamBuffer Class it will not compare every byte of the ByteBuffer if I am not wrong,

Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

@sadanand48 , thanks for the update. Just a few minor comments inlined.

Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

+1 the latest change look good.

szetszwo pushed a commit to szetszwo/ozone that referenced this pull request May 6, 2022
captainzmc pushed a commit to captainzmc/hadoop-ozone that referenced this pull request Jul 4, 2022
szetszwo pushed a commit that referenced this pull request Oct 25, 2022
(cherry picked from commit 3daf3d7)
(cherry picked from commit 508fda8744a9bd04bb1cb6c4ee12df5581e4dded)
szetszwo pushed a commit that referenced this pull request Nov 7, 2022
(cherry picked from commit 3daf3d7)
(cherry picked from commit 508fda8744a9bd04bb1cb6c4ee12df5581e4dded)
(cherry picked from commit 5b73b51)
szetszwo pushed a commit that referenced this pull request Dec 1, 2022
szetszwo pushed a commit that referenced this pull request Dec 16, 2022
nishitpatira pushed a commit to nishitpatira/ozone that referenced this pull request Dec 16, 2022
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.

3 participants