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

connection: Do not reset delayed closed timer if doWrite consumes 0 bytes from the output buffer. #11833

Conversation

antoniovicente
Copy link
Contributor

@antoniovicente antoniovicente commented Jul 1, 2020

Commit Message: connection: Do not reset delayed closed timer if doWrite consumes 0 bytes from the output buffer.
Additional Description: Only reset the delayed close timer if the write attempt made progress. This works around spurious fd Write events which are delivered to a connection even after it manages to fully drain the output buffer and should be waiting for client FIN or the delay close timer to expire. This is known to happen when listening for level events instead of edge-trigger fd events.
Risk Level: medium, changes to timeout behavior.
Testing: unit
Docs Changes: n/a
Release Notes: n/a
Fixes #11829

…ytes from the output buffer.

Signed-off-by: Antonio Vicente <avd@google.com>
@antoniovicente
Copy link
Contributor Author

/cc @davinci26

Hey Sotiris,

Can you double check that this change addresses your problem?

delayed_close_timer_->enableTimer(delayed_close_timeout_);
ASSERT(delayed_close_timer_ != nullptr && delayed_close_timer_->enabled());
if (result.bytes_processed_ > 0) {
delayed_close_timer_->enableTimer(delayed_close_timeout_);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think there's a way to distinguish between these two enableTimer calls in tests. Ideally we would move delayed_close_state_ to a WaitingForClose state or change the fd mask to:
file_event_->setEnabled(enable_half_close_ ? 0 : Event::FileReadyType::Closed);
to avoid getting any Write events past this point.

Copy link
Contributor

Choose a reason for hiding this comment

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

nah, but I'll trust you made sure your test would fail without the code change :-)

@antoniovicente
Copy link
Contributor Author

/assign @davinci26

@repokitteh-read-only
Copy link

@davinci26 cannot be assigned to this issue.

🐱

Caused by: a #11833 (comment) was created by @antoniovicente.

see: more, trace.

@davinci26
Copy link
Member

LGTM it address the issue. I have verified it locally in my devbox

…_only_if_made_progress

Signed-off-by: Antonio Vicente <avd@google.com>
Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

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

LGTM, though I'd bump the risk to medium because event loop changes. I'll merge after we cut the release :-)

delayed_close_timer_->enableTimer(delayed_close_timeout_);
ASSERT(delayed_close_timer_ != nullptr && delayed_close_timer_->enabled());
if (result.bytes_processed_ > 0) {
delayed_close_timer_->enableTimer(delayed_close_timeout_);
Copy link
Contributor

Choose a reason for hiding this comment

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

nah, but I'll trust you made sure your test would fail without the code change :-)

@antoniovicente
Copy link
Contributor Author

antoniovicente commented Jul 7, 2020

LGTM, though I'd bump the risk to medium because event loop changes. I'll merge after we cut the release :-)

Bumped up to medium.

Thanks!

@alyssawilk alyssawilk merged commit 5960533 into envoyproxy:master Jul 7, 2020
jwendell pushed a commit to istio/envoy that referenced this pull request Jul 21, 2020
* Revert "test: shard http2_integration_test (envoyproxy#11939)"

This reverts commit 2026ec2.

* Revert "fuzz: added fuzz test for listener filter original_dst (envoyproxy#11847)"

This reverts commit 673cab8.

* Revert "docs: updating release instructions (envoyproxy#11938)"

This reverts commit 09b96a5.

* Revert "test: remove superfluous test dependencies (envoyproxy#11912)"

This reverts commit 5e9fb8a.

* Revert "dynamic_forward_proxy: cleanup integration test (envoyproxy#11891)"

This reverts commit 11a4667.

* Revert "preliminary PR to Porting Envoy to C++17 (envoyproxy#11840)"

This reverts commit 9ad964d.

* Revert "connection: Do not reset delayed closed timer if doWrite consumes 0 bytes from the output buffer. (envoyproxy#11833)"

This reverts commit 5960533.

* Revert "threadlocal: avoiding a dynamic cast in opt builds (envoyproxy#11900)"

This reverts commit 363b104.

* Revert "release: kicking off 1.16.0 (envoyproxy#11930)"

This reverts commit ef74d8f.

Signed-off-by: Lizan Zhou <lizan@tetrate.io>
scheler pushed a commit to scheler/envoy that referenced this pull request Aug 4, 2020
…ytes from the output buffer. (envoyproxy#11833)

Commit Message: connection: Do not reset delayed closed timer if doWrite consumes 0 bytes from the output buffer.
Additional Description: Only reset the delayed close timer if the write attempt made progress. This works around spurious fd Write events which are delivered to a connection even after it manages to fully drain the output buffer and should be waiting for client FIN or the delay close timer to expire. This is known to happen when listening for level events instead of edge-trigger fd events.
Risk Level: medium, changes to timeout behavior.
Testing: unit
Docs Changes: n/a
Release Notes: n/a
Fixes envoyproxy#11829

Signed-off-by: Antonio Vicente <avd@google.com>
Signed-off-by: scheler <santosh.cheler@appdynamics.com>
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.

Setting event priorities to work around level based events
3 participants