Repository navigation
http: add AsyncStream buffer size limit for upstream retry - #19611
Conversation
Signed-off-by: Shikugawa <[email protected]>
mattklein123
left a comment
There was a problem hiding this comment.
Thanks for working on this. Small comments to get started.
/wait
| // buffering that we allow here. | ||
| if (buffered_body_ != nullptr) { | ||
| if (buffered_body_ != nullptr && | ||
| buffered_body_->length() + data.length() <= buffered_body_size_limit_) { |
There was a problem hiding this comment.
In the case where we exceed the limit, shouldn't we fail in some way? This is going to lead to corruption and hard to debug issues?
There was a problem hiding this comment.
If an attempt is made to perform a retry when the buffer is exceeded, a failure flag is added as follows:
void AsyncStreamImpl::sendData(Buffer::Instance& data, bool) {
...
if (buffer != nullptr) {
if (isExceeded(buffer.size() + data.size(), BUFFER_LIMIT)) {
should_fail_retry_ = true;
} else {
buffer.add(...)
}
}
...
}If should_fail_retry_ is set to true, it tries to delete the stream before scheduling the retry.
This method requires some interface changes, but it avoids implementations that delete the stream when the buffer is exceeded even though retries will never occur in the future. What do you think?
Another idea would be to delete old messages when the buffer exceeds a certain size, like a ring buffer.
There was a problem hiding this comment.
For now, the current changes will fix the memory leak bug. Anyway, this change should be upstreamed immediately, and the follow-up changes can be implemented later (before the next release). In the meantime, we can deal with it by simply dumping the logs.
There was a problem hiding this comment.
Please add relevant TODOs, etc. You might also consider a power of 2 backoff warning log of some type until there is a better fix here. People should know this is happening.
|
@Shikugawa do you have an ETA for this? I'd like to share with envoy-announce@ when this lands so we can advise folks to bump. |
Not yet. But I keep in mind it. I will notify you when this change is landed. |
|
@mattklein123 Could you take a look? |
Signed-off-by: Shikugawa <[email protected]>
Signed-off-by: Shikugawa <[email protected]>
|
Please merge main to fix CI. /wait |
…r-limit Signed-off-by: Shikugawa <[email protected]>
Signed-off-by: Shikugawa <[email protected]>
…r-limit Signed-off-by: Shikugawa <[email protected]>
Signed-off-by: Shikugawa <[email protected]>
| // TODO(shikugawa): In addition to logging, the process of preventing too much data by using | ||
| // ring buffers, etc. |
There was a problem hiding this comment.
I'm not sure what this means, can you clarify? Thank you.
| namespace { | ||
| // Limit the size of buffer for data used for retries. | ||
| // The default is set to 64KB. Since the existence of a buffer for | ||
| // retries is non-trivial to the user, this value is not varied. |
There was a problem hiding this comment.
Sorry what do you mean non-trivial to the user?
There was a problem hiding this comment.
This means that the user does not need to be aware of the existence of the retry buffer at this time because the buffer size is fixed length, but it is difficult to understand, so it will be removed.
Signed-off-by: Shikugawa <[email protected]>
|
/retest |
|
Retrying Azure Pipelines: |
|
/retest |
|
Retrying Azure Pipelines: |
mattklein123
left a comment
There was a problem hiding this comment.
Some comment clarifications otherwise LGTM, thanks.
/wait
Signed-off-by: Shikugawa <[email protected]>
Signed-off-by: Shikugawa [email protected]
Commit Message: http: add AsyncStream buffer size limit for upstream retry
Additional Description: This PR fixes the potential memory leak on long-lived HTTP streams, such as gRPC client streaming.
Risk Level: Low
Testing: Unit
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]
Fixes #19699