Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions source/common/http/http1/conn_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ void ConnPoolImpl::createNewConnection() {

ConnectionPool::Cancellable* ConnPoolImpl::newStream(StreamDecoder& response_decoder,
ConnectionPool::Callbacks& callbacks) {
host_->cluster().stats().upstream_rq_total_.inc();
host_->stats().rq_total_.inc();
if (!ready_clients_.empty()) {
host_->cluster().stats().upstream_rq_total_.inc();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you potentially move this into attachRequestToCleint() and remove from below? I think it's better to have the logic in one place and it's more accurate since we still may not send the request upstream if it gets cancelled while pending.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This makes sense to me, thanks for catching that pending request case.

host_->stats().rq_total_.inc();

ready_clients_.front()->moveBetweenLists(ready_clients_, busy_clients_);
ENVOY_CONN_LOG(debug, "using existing connection", *busy_clients_.front()->codec_client_);
attachRequestToClient(*busy_clients_.front(), response_decoder, callbacks);
Expand All @@ -106,6 +107,9 @@ ConnectionPool::Cancellable* ConnPoolImpl::newStream(StreamDecoder& response_dec
host_->cluster().stats().upstream_cx_overflow_.inc();
}

host_->cluster().stats().upstream_rq_total_.inc();
host_->stats().rq_total_.inc();

// If we have no connections at all, make one no matter what so we don't starve.
if ((ready_clients_.size() == 0 && busy_clients_.size() == 0) || can_create_connection) {
createNewConnection();
Expand Down
3 changes: 3 additions & 0 deletions test/common/http/http1/conn_pool_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ TEST_F(Http1ConnPoolImplTest, MaxPendingRequests) {
cluster_->resetResourceManager(1, 1, 1024, 1);

EXPECT_EQ(0U, cluster_->circuit_breakers_stats_.rq_pending_open_.value());
EXPECT_EQ(0U, cluster_->stats_.upstream_rq_total_.value());

NiceMock<Http::MockStreamDecoder> outer_decoder;
ConnPoolCallbacks callbacks;
Expand All @@ -307,6 +308,7 @@ TEST_F(Http1ConnPoolImplTest, MaxPendingRequests) {
EXPECT_EQ(nullptr, handle2);

EXPECT_EQ(1U, cluster_->circuit_breakers_stats_.rq_pending_open_.value());
EXPECT_EQ(1U, cluster_->stats_.upstream_rq_total_.value());

handle->cancel();

Expand All @@ -315,6 +317,7 @@ TEST_F(Http1ConnPoolImplTest, MaxPendingRequests) {
dispatcher_.clearDeferredDeleteList();

EXPECT_EQ(1U, cluster_->stats_.upstream_rq_pending_overflow_.value());
EXPECT_EQ(1U, cluster_->stats_.upstream_rq_total_.value());
}

/**
Expand Down