Repository navigation
quic: postpone conn pool connect - #19860
Conversation
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
RyanTheOptimist
left a comment
There was a problem hiding this comment.
This looks promising, but I don't think I understand what kinds of network events might be received during creation and why they necessarily need to be passed to the pool when they're generated (but only for HTTP/3). I suspect this is related to 0-RTT. Looking at the existing Grid tests, it looks like we already correctly handle the case where there is a failure during connect() so presumably that event is (somehow) handled successfully. Does that mechanism not work for the 0-RTT case?
| uint32_t concurrent_stream_limit); | ||
| ~ActiveClient() override; | ||
|
|
||
| virtual void onEnlisted() {} |
There was a problem hiding this comment.
Can you add a comment which explains when this is called (and what "enlisted" means in this context).
There was a problem hiding this comment.
Ah, great! I wonder if "initialized" might be more readable? WDYT?
There was a problem hiding this comment.
ActiveClient already has a method called initialize() so I was trying to avoid similar names.
| pending->cancel(Envoy::ConnectionPool::CancelPolicy::CloseExcess); | ||
| onPoolFailure(nullptr, absl::string_view(), ConnectionPool::PoolFailureReason::Overflow, | ||
| context); | ||
| } |
There was a problem hiding this comment.
Can we add unit tests for the new code in this file?
There was a problem hiding this comment.
Modified h3 pool test and grid test to cover these changes.
There was a problem hiding this comment.
Having the h3 pool and grid pool tests cover this is good. I notice that we have conn_pool_base_test.cc so I'm wondering if we could add a ConnPoolImplBase test there. But maybe that file doesn't really have such tests?
There was a problem hiding this comment.
Added a test in conn_pool_base_test.cc to verify the new way purges all pending streams.
| pool->dispatcher(), pool->randomGenerator()) | ||
| : std::make_unique<CodecClientProd>(CodecType::HTTP3, std::move(data.connection_), | ||
| data.host_description_, pool->dispatcher(), | ||
| pool->randomGenerator()); |
There was a problem hiding this comment.
Can we unit test these changes?
There was a problem hiding this comment.
It is covered in the grid test with parameterized the runtime guard.
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Friendly ping? |
Currently network event during connect() is not propagate via network callbacks as connect() happens before that. They have been handled via checking if the connection gets closed during client creation and if yes, failing the client creation and propagate onPoolFailure() (see |
RyanTheOptimist
left a comment
There was a problem hiding this comment.
Thanks for the explanation! That makes a lot of sense. I think this looks pretty good. I do have one question about whether it might make sense to only have the "no connect" case in order to simplify things, but maybe that's problematic?
| pending->cancel(Envoy::ConnectionPool::CancelPolicy::CloseExcess); | ||
| onPoolFailure(nullptr, absl::string_view(), ConnectionPool::PoolFailureReason::Overflow, | ||
| context); | ||
| } |
There was a problem hiding this comment.
Having the h3 pool and grid pool tests cover this is good. I notice that we have conn_pool_base_test.cc so I'm wondering if we could add a ConnPoolImplBase test there. But maybe that file doesn't really have such tests?
| uint32_t concurrent_stream_limit); | ||
| ~ActiveClient() override; | ||
|
|
||
| virtual void onEnlisted() {} |
There was a problem hiding this comment.
Ah, great! I wonder if "initialized" might be more readable? WDYT?
| ASSERT(codec_client_); | ||
| if (dynamic_cast<CodecClientProd*>(codec_client_.get()) == nullptr) { | ||
| // Hasn't called connect() yet. | ||
| codec_client_->connect(); |
There was a problem hiding this comment.
Presumably this only happen in the case where the runtime flag is false? We could ASSERT() this here, but maybe that's not worth it?
| TestScopedRuntime scoped_runtime; | ||
| Runtime::LoaderSingleton::getExisting()->mergeValues( | ||
| {{"envoy.reloadable_features.postpone_h3_client_connect_till_enlisted", | ||
| (GetParam() ? "true" : "false")}}); |
There was a problem hiding this comment.
Is this the only test that uses the new parameterization? If so, I wonder if we can create a new test fixture for this class and just parameterize that to avoid running all the other tests twice.
| ActiveClient& client_ref = *client; | ||
| LinkedList::moveIntoList(std::move(client), owningList(client->state())); | ||
| client_ref.onEnlisted(); | ||
| if (client_ref.state() == ActiveClient::State::CLOSED) { |
There was a problem hiding this comment.
I'm guessing this is needed because onEnlisted might call connect and that might fail? So this is basically the same case as up on line 146 but this is the "no connect" case, and that is the "connect" case?
There was a problem hiding this comment.
Yes, this if block handles connection close during connect(). But the one in 146 covers more than connect failure, but also the case where transport socket factory wasn't even finished config update during connection creation in H3.
| context); | ||
| // This currently only happens for HTTP/3 if 1) secrets aren't yet loaded, | ||
| // or 2) connect failed immediately. | ||
| if (!pending_streams_.empty()) { |
There was a problem hiding this comment.
I'm not quite sure I understand why this is needed, but wasn't needed before. Can you elaborate?
There was a problem hiding this comment.
Before pending wasn't purged so it got purged here. But now the connection close event callback would have purged all the pending streams.
There was a problem hiding this comment.
any chance we can just avoid this at the call site for (1) rather than here to avoid "sometimes done here, sometimes done elsewhere"?
There was a problem hiding this comment.
No longer has 2 failure cases, but the failure reason probably shouldn't be ConnectionPool::PoolFailureReason::Overflow as used here.
|
|
||
| /** | ||
| * Production implementation that installs a real codec without automatically connecting. | ||
| */ |
There was a problem hiding this comment.
I wonder if instead of having two different types of codeclients (one which calls connect and one which doesn't) if we could always go with this new "no connect" codepath. I'm wondering if we would be able to eliminate some complexity by only having one path? Maybe that's not feasible. What do you think?
Signed-off-by: Dan Zhang <[email protected]>
Are you thinking about changing CodecClientProd not to call connect() in its constructor? As to the codec client used in http1 and http2 conn pool, I guess their connect() can be postponed without problem. Even if not, I believe functionally we can always add a following connect() call to all its call sites. |
Yeah, that's what I was thinking. Thanks for explaining. I think that makes sense. (Because GitHub code review is a bit tricky to follow, there are still a few outstanding comments. I'll take another look after they're addressed.) |
|
/wait-any |
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
RyanTheOptimist
left a comment
There was a problem hiding this comment.
Looks good. Thanks!
|
/retest |
|
Retrying Azure Pipelines: |
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
|
/retest |
|
Retrying Azure Pipelines: |
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
alyssawilk
left a comment
There was a problem hiding this comment.
cc @zuercher for !Google pass
| */ | ||
| class NoConnectCodecClientProd : public CodecClient { | ||
| public: | ||
| NoConnectCodecClientProd(CodecType type, Network::ClientConnectionPtr&& connection, |
There was a problem hiding this comment.
OK, how about a TODO to remove the extra class once the guard is deprecated then? It wasn't clear to me it was going away.
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
Signed-off-by: Dan Zhang <[email protected]>
|
/retest |
|
Retrying Azure Pipelines: |
| Network::Connection& connection = *data.connection_; | ||
| auto client = std::make_unique<ActiveClient>(*pool, data); | ||
| if (connection.state() == Network::Connection::State::Closed) { | ||
| ASSERT(dynamic_cast<CodecClientProd*>(client->codec_client_.get()) != nullptr); |
There was a problem hiding this comment.
nit: I guess I'd add a note here about removing this conditional when the runtime flag is removed, but I don't think it gates approval.
Signed-off-by: Dan Zhang <[email protected]>
|
/retest |
|
Retrying Azure Pipelines: |
|
/retest |
|
Retrying Azure Pipelines: |
Signed-off-by: Dan Zhang <[email protected]>
|
Ping for merge |
|
@RyanTheOptimist for mege |
Commit Message: Currently H3 connection pool makes connect attempt during ActiveClient creation. So any network event during handshake won't be propagated to the pool because the network callbacks are not wired up yet. This change creates a type of CodecClient which doesn't call connect() during construction and uses it for H3 pool. The Http3::ConnectionPool::ActiveClient will defer connect() till next event loop.
Risk Level: medium, h3 connection pool only
Testing: existing tests pass
Runtime guard: envoy.reloadable_features.postpone_h3_client_connect_to_next_loop
Part of: #18715