Skip to content

grpc: implement TTL manager to re-buffer pending messages for bidirectional gRPC#18987

Merged
snowp merged 12 commits intoenvoyproxy:mainfrom
Shikugawa:buffered-message-ttl-manager
Feb 8, 2022
Merged

grpc: implement TTL manager to re-buffer pending messages for bidirectional gRPC#18987
snowp merged 12 commits intoenvoyproxy:mainfrom
Shikugawa:buffered-message-ttl-manager

Conversation

@Shikugawa
Copy link
Member

@Shikugawa Shikugawa commented Nov 12, 2021

Signed-off-by: Shikugawa rei@tetrate.io

Commit Message: grpc: implement TTL manager to re-buffer pending messages for bidirectional gRPC
Additional Description: Related with #17486. This PR provides the TTL manager for buffered bidirectional gRPC messages.
Risk Level: Low
Testing: Unit
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]

…ages

Signed-off-by: Shikugawa <rei@tetrate.io>
@repokitteh-read-only
Copy link

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #18987 was opened by Shikugawa.

see: more, trace.

Signed-off-by: Shikugawa <rei@tetrate.io>
@Shikugawa Shikugawa marked this pull request as ready for review November 12, 2021 11:44
@Shikugawa Shikugawa requested review from lizan and snowp November 12, 2021 11:44
Signed-off-by: Shikugawa <rei@tetrate.io>
@Shikugawa Shikugawa changed the title grpc: implement TTL manager to track buffered bidirectional gRPC messages grpc: implement TTL manager to re-buffer pending messages for bidirectional gRPC Nov 12, 2021
@yanavlasov yanavlasov self-assigned this Nov 12, 2021
Signed-off-by: Shikugawa <rei@tetrate.io>
@Shikugawa
Copy link
Member Author

@yanavlasov PTAL

@lizan lizan added the waiting label Nov 17, 2021
Signed-off-by: Shikugawa <rei@tetrate.io>
Copy link
Contributor

@yanavlasov yanavlasov left a comment

Choose a reason for hiding this comment

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

Is this PR complete? I do not see how the BufferedMessageTtlManager is being used. As such it is hard to reason about some of the decisions, like using flat_has_set of message ids in the TTL manager.

/wait-any

Signed-off-by: Shikugawa <rei@tetrate.io>
@Shikugawa
Copy link
Member Author

Shikugawa commented Dec 1, 2021

Is this PR complete? I do not see how the BufferedMessageTtlManager is being used. As such it is hard to reason about some of the decisions, like using flat_has_set of message ids in the TTL manager.

Yes. This is a part of supporting #17486. This feature will be utilized there.

@Shikugawa
Copy link
Member Author

@yanavlasov Could you take a look?

@phlax
Copy link
Member

phlax commented Dec 15, 2021

ping @yanavlasov

@jmarantz
Copy link
Contributor

jmarantz commented Jan 6, 2022

/assign-from @envoyproxy/first-pass-reviewers

@repokitteh-read-only
Copy link

@envoyproxy/first-pass-reviewers assignee is @wrowe

🐱

Caused by: a #18987 (comment) was created by @jmarantz.

see: more, trace.

@alyssawilk
Copy link
Contributor

@wrowe ping!

Copy link
Contributor

@snowp snowp left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! The logic seems right to me, just a few comments to make this easier for people to understand

Signed-off-by: Shikugawa <rei@tetrate.io>
Signed-off-by: Shikugawa <rei@tetrate.io>
Signed-off-by: Shikugawa <rei@tetrate.io>
Copy link
Contributor

@snowp snowp left a comment

Choose a reason for hiding this comment

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

Thanks for iterating on this! A few more comments

NiceMock<Upstream::MockClusterManager> cm_;
NiceMock<Http::MockAsyncClient> http_client_;
Http::MockAsyncClientStream http_stream_;
DangerousDeprecatedTestTime test_time_;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use simulated test time here instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Simulated test time is no longer needed here. Thus I deleted it.

dispatcher_->run(Event::Dispatcher::RunType::Block);
EXPECT_EQ(ttl_manager_->deadlineForTest().size(), 0);

// Test if deadline queue is empty after queue cleared once.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this comment be before L54?

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

Signed-off-by: Shikugawa <rei@tetrate.io>
Copy link
Contributor

@snowp snowp left a comment

Choose a reason for hiding this comment

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

Thanks! A few comments on the documentation wording

@snowp snowp added the waiting label Jan 24, 2022
Signed-off-by: Shikugawa <rei@tetrate.io>
Copy link
Contributor

@snowp snowp left a comment

Choose a reason for hiding this comment

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

A suggestion for the comment wording, otherwise LG

/wait

Comment on lines +12 to +20
// The TTL Manager can be given a set of IDs that are expected to expire at the same time.
// When checking for ID expiration, an expiration callback will be called for each ID belonging to
// this set of IDs. This class is used to manage the lifetime of messages stored in
// BufferedAsyncClient. Messages whose survival period has expired will be deleted from the Buffer.
// It allows monitoring a set of IDs for expiration, triggering a callback upon expiration.
// This class is able to monitor multiple sets of IDs at the same time, even after some of them have
// expired. When the callback is invoked, the callback given to the constructor will be will be
// executed for each of the TTL-elapsed IDs. After that, if the IDs to be monitored is not empty,
// the manager will continue to monitor for expiration again.
Copy link
Contributor

Choose a reason for hiding this comment

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

This still seems a bit repetitive, how about:

This class is used to manage the TTL for pending uploads within a BufferedAsyncClient. Multiple IDs
can be inserted into the TTL manager at once, all with the same TTL (specified in the constructor). Upon expiry,
the TTL manager will invoke the provided expiry callback for each ID. Note that there is no way to disable
the expiration, and so it's up to the recipient of the callback to handle this. BufferedAsyncClient will do
the right thing here: if the expired ID is still in flight it will be returned to the buffer, otherwise it does nothing.

The TTL manager is designed to handle multiple sets of IDs inserted at various times, backing this with a
single Timer. This allows us to track a large amount of IDs inserted at different times without using a lot of
different timers, which could put undue pressure on the event loop.

?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for your suggestion!

Signed-off-by: Shikugawa <rei@tetrate.io>
Copy link
Contributor

@snowp snowp left a comment

Choose a reason for hiding this comment

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

Thanks!

@snowp snowp merged commit 818e044 into envoyproxy:main Feb 8, 2022
joshperry pushed a commit to joshperry/envoy that referenced this pull request Feb 13, 2022
…tional gRPC (envoyproxy#18987)

Signed-off-by: Shikugawa <rei@tetrate.io>
Signed-off-by: Josh Perry <josh.perry@mx.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.

8 participants