From d50e8f37bec264fb5c53eb4496944ebcad230c4f Mon Sep 17 00:00:00 2001 From: dinesh-murugiah Date: Thu, 14 Nov 2024 21:10:54 +0530 Subject: [PATCH] remove assert and add logs when response received after request flushed --- .../filters/network/redis_proxy/proxy_filter.cc | 14 +++++++++++++- .../filters/network/redis_proxy/proxy_filter.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/source/extensions/filters/network/redis_proxy/proxy_filter.cc b/source/extensions/filters/network/redis_proxy/proxy_filter.cc index ab6fa28b7311..92f3b90e4939 100644 --- a/source/extensions/filters/network/redis_proxy/proxy_filter.cc +++ b/source/extensions/filters/network/redis_proxy/proxy_filter.cc @@ -118,8 +118,11 @@ void ProxyFilter::onEvent(Network::ConnectionEvent event) { while (!pending_requests_.empty()) { if (pending_requests_.front().request_handle_ != nullptr) { pending_requests_.front().request_handle_->cancel(); + }else{ + ENVOY_LOG(error,"pending request handle is null"); } pending_requests_.pop_front(); + request_cancelled_=true; } if (event == Network::ConnectionEvent::RemoteClose){ ENVOY_LOG(debug,"dereferencing pubsub callback and transaction on exit from proxy filter"); @@ -246,7 +249,16 @@ void ProxyFilter::onPubsubConnClose(){ } void ProxyFilter::onResponse(PendingRequest& request, Common::Redis::RespValuePtr&& value) { - ASSERT(!pending_requests_.empty()); + //Commenting this out for Trackign an issue in freshchat where the pending_requests_ is empty but we get a response + //ASSERT(!pending_requests_.empty()); + if (pending_requests_.empty()) { + ENVOY_LOG(error, "Received response:'{}' with no pending requests - discarding response",value->toString()); + ENVOY_LOG(error, "cancel request '{}' when no pending requests",request_cancelled_?"true":"false"); + if (request.request_handle_ != nullptr) { + request.request_handle_=nullptr; + } + return; + } request.pending_response_ = std::move(value); request.request_handle_ = nullptr; diff --git a/source/extensions/filters/network/redis_proxy/proxy_filter.h b/source/extensions/filters/network/redis_proxy/proxy_filter.h index 37fcefa12388..cac181ed48e8 100644 --- a/source/extensions/filters/network/redis_proxy/proxy_filter.h +++ b/source/extensions/filters/network/redis_proxy/proxy_filter.h @@ -159,6 +159,7 @@ class ProxyFilter : public Network::ReadFilter, bool connection_allowed_; Common::Redis::Client::Transaction transaction_; bool connection_quit_; + bool request_cancelled_{false}; std::string clientname_{}; };