-
Notifications
You must be signed in to change notification settings - Fork 5.3k
refactor router filter to store upstream requests in a list. #6540
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
Changes from all commits
42149c6
6be4b93
8a9e93e
ed85803
5c66169
f86b421
679f4d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1547,16 +1547,16 @@ bool ConnectionManagerImpl::ActiveStream::verbose() const { | |
|
|
||
| void ConnectionManagerImpl::ActiveStream::callHighWatermarkCallbacks() { | ||
| ++high_watermark_count_; | ||
| if (watermark_callbacks_) { | ||
| watermark_callbacks_->onAboveWriteBufferHighWatermark(); | ||
| for (auto watermark_callbacks : watermark_callbacks_) { | ||
| watermark_callbacks->onAboveWriteBufferHighWatermark(); | ||
| } | ||
| } | ||
|
|
||
| void ConnectionManagerImpl::ActiveStream::callLowWatermarkCallbacks() { | ||
| ASSERT(high_watermark_count_ > 0); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm looking at this and I think there may be a pre-existing bug which worked OK before because there was one back-up cause, but will not work with two. If you have the upstream connection call high watermark callbacks, and increment high_watermark_count_, then the hedge connection hits its watermark and increments high_watermark_count_, I don't think we want to resume by calling the low watermark callbacks until the count is back to 0. If I'm correct here we may have been overenthusiastic resuming, but fixing will be a fairly high risk change.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the reason the fix is high risk because the count might not reach 0 if there is a counting bug somewhere?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep. I mean you can land this and do the other separately but I don't think you can land your hedge fixes without both, and the fix is high risk because it may be masking other bugs. |
||
| --high_watermark_count_; | ||
| if (watermark_callbacks_) { | ||
| watermark_callbacks_->onBelowWriteBufferLowWatermark(); | ||
| for (auto watermark_callbacks : watermark_callbacks_) { | ||
| watermark_callbacks->onBelowWriteBufferLowWatermark(); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1891,19 +1891,20 @@ void ConnectionManagerImpl::ActiveStreamDecoderFilter:: | |
|
|
||
| void ConnectionManagerImpl::ActiveStreamDecoderFilter::addDownstreamWatermarkCallbacks( | ||
mpuncel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| DownstreamWatermarkCallbacks& watermark_callbacks) { | ||
| // This is called exactly once per stream, by the router filter. | ||
| // If there's ever a need for another filter to subscribe to watermark callbacks this can be | ||
| // turned into a vector. | ||
| ASSERT(parent_.watermark_callbacks_ == nullptr); | ||
| parent_.watermark_callbacks_ = &watermark_callbacks; | ||
| // This is called exactly once per upstream-stream, by the router filter. Therefore, we | ||
| // expect the same callbacks to not be registered twice. | ||
| ASSERT(std::find(parent_.watermark_callbacks_.begin(), parent_.watermark_callbacks_.end(), | ||
| &watermark_callbacks) == parent_.watermark_callbacks_.end()); | ||
| parent_.watermark_callbacks_.emplace(parent_.watermark_callbacks_.end(), &watermark_callbacks); | ||
| for (uint32_t i = 0; i < parent_.high_watermark_count_; ++i) { | ||
| watermark_callbacks.onAboveWriteBufferHighWatermark(); | ||
| } | ||
| } | ||
| void ConnectionManagerImpl::ActiveStreamDecoderFilter::removeDownstreamWatermarkCallbacks( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you poke through code and make sure if upstream connection 1 is above the high watermark (and causes the state to transition to high watermark) and upstream connection 2 ends up paused, that if upstream connection 1 goes away that it clears the state so that 2 ends up resuming? We want to make sure we don't get wedged here. |
||
| DownstreamWatermarkCallbacks& watermark_callbacks) { | ||
| ASSERT(parent_.watermark_callbacks_ == &watermark_callbacks); | ||
| parent_.watermark_callbacks_ = nullptr; | ||
| ASSERT(std::find(parent_.watermark_callbacks_.begin(), parent_.watermark_callbacks_.end(), | ||
| &watermark_callbacks) != parent_.watermark_callbacks_.end()); | ||
| parent_.watermark_callbacks_.remove(&watermark_callbacks); | ||
| } | ||
|
|
||
| bool ConnectionManagerImpl::ActiveStreamDecoderFilter::recreateStream() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should enhance existing unit tests to have two subscribers, to regression test both get the callback