Fix Envoy Mobile bug where writing prevents the read loop from running,#2221
Conversation
by scheduling repeated onSendWindowAvailable calls in the next dispatcher iteration. Adds the regression test Charles cooked up in envoyproxy#2212 Fixes envoyproxy#2213 Signed-off-by: Ryan Hamilton <rch@google.com>
9902a88 to
a943abc
Compare
|
@alyssawilk please take a look. I'm not entirely sure if this is the right approach. |
Signed-off-by: Ryan Hamilton <rch@google.com>
|
FYI: This PR is not complete; I'm looking for guidance if this approach seems reasonable. |
alyssawilk
left a comment
There was a problem hiding this comment.
yeah I think this is the right away to go about it, thanks for tackling it! I'd be inclined to unit test as well as you get it ready.
library/common/http/client.cc
Outdated
| if (direct_stream->read_disable_count_ == 0) { | ||
| // If there is still buffer space after the write, notify the sender | ||
| // that send window is available. | ||
| // that send window is available, on the next dispatcher iteration. |
There was a problem hiding this comment.
Think it's worth commenting why the delay?
There was a problem hiding this comment.
Sure. Done.
| // that send window is available, on the next dispatcher iteration. | ||
| direct_stream->wants_write_notification_ = false; | ||
| direct_stream->callbacks_->onSendWindowAvailable(); | ||
| scheduled_callback_ = dispatcher_.createSchedulableCallback( |
There was a problem hiding this comment.
can't remember offhand: do we need to create a new one each time, or only the one time?
There was a problem hiding this comment.
Oh nice. That seems to work. Done!
There was a problem hiding this comment.
apparently it didn't work - can we call out why we always need to create in a comment?
There was a problem hiding this comment.
Good point. Done.
Signed-off-by: Ryan Hamilton <rch@google.com>
Signed-off-by: Ryan Hamilton <rch@google.com>
RyanTheOptimist
left a comment
There was a problem hiding this comment.
Unit test coverage added via the changes to the existing tests.
library/common/http/client.cc
Outdated
| if (direct_stream->read_disable_count_ == 0) { | ||
| // If there is still buffer space after the write, notify the sender | ||
| // that send window is available. | ||
| // that send window is available, on the next dispatcher iteration. |
There was a problem hiding this comment.
Sure. Done.
| // that send window is available, on the next dispatcher iteration. | ||
| direct_stream->wants_write_notification_ = false; | ||
| direct_stream->callbacks_->onSendWindowAvailable(); | ||
| scheduled_callback_ = dispatcher_.createSchedulableCallback( |
There was a problem hiding this comment.
Oh nice. That seems to work. Done!
|
@danzh2010 FYI |
|
@jpsim Would you mind taking a look at this? Or redirect if someone else would be a better choice? |
|
@goaway as per our discussion in the community meeting, what do you think of this change? |
goaway
left a comment
There was a problem hiding this comment.
Based on our discussion this past week, and given the fact that this is all effectively guarded by the explicit flow control flag (which is off by default), I think it's reasonable to move forward with this.
Thanks for the discussion and investigation @RyanTheOptimist and @carloseltuerto.
|
Rerunning the failed CI job. |
Signed-off-by: Ryan Hamilton <rch@google.com>
ad82119 to
648522a
Compare
Signed-off-by: Ryan Hamilton <rch@google.com>
alyssawilk
left a comment
There was a problem hiding this comment.
ugh, I want to prematurely optimize that callback creation so badly :-P
|
Thanks, @RyanTheOptimist! |
|
When removing this line,
This unfortunately, this ends up with crash more than 50% of the time: |
* main: build: remove dist/ (#2184) Fix Envoy Mobile bug where writing prevents the read loop from running, (#2221) Add comments to CronetBidirectionalStream (#2266) CronetBidirectionalStream (#2164) ci: update build image (#2261) Bump Lyft Support Rotation (#2260) Signed-off-by: JP Simard <jp@jpsim.com>
* main: build: remove dist/ (#2184) Fix Envoy Mobile bug where writing prevents the read loop from running, (#2221) Add comments to CronetBidirectionalStream (#2266) CronetBidirectionalStream (#2164) ci: update build image (#2261) Bump Lyft Support Rotation (#2260) Signed-off-by: JP Simard <jp@jpsim.com>
* main: Add assert when failing to get_env (#2253) Update Kotlin standard libraries to 1.6.21 (#2256) iOS: Change release artifacts to use xcframeworks (#2217) build: remove dist/ (#2184) Fix Envoy Mobile bug where writing prevents the read loop from running, (#2221) Add comments to CronetBidirectionalStream (#2266) CronetBidirectionalStream (#2164) Signed-off-by: JP Simard <jp@jpsim.com>
Fix Envoy Mobile bug where writing prevents the read loop from running,
by scheduling repeated onSendWindowAvailable calls in the next
dispatcher iteration.
Adds the regression test Charles cooked up in #2212
Fixes #2213
Risk Level: Low
Testing: New regression test
Docs Changes: N/A
Release Notes: N/A