This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
commit 6462d913ca127aa5fcffdc16aa288ec22f44b700 Author: Pxl <[email protected]> AuthorDate: Thu Mar 21 20:10:02 2024 +0800 [Improvement](brpc) log error message when AutoReleaseClosure meet brpc error or response… (#32628) log error message when AutoReleaseClosure meet brpc error or response with error status --- be/src/util/ref_count_closure.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/be/src/util/ref_count_closure.h b/be/src/util/ref_count_closure.h index 14a136fcfd0..7bbcfb7da39 100644 --- a/be/src/util/ref_count_closure.h +++ b/be/src/util/ref_count_closure.h @@ -68,6 +68,19 @@ public: // std::unique_ptr<AutoReleaseClosure> a(b); // brpc_call(a.release()); +template <typename T> +concept HasStatus = requires(T* response) { response->status(); }; + +template <typename Response> +void process_status(Response* response) {} + +template <HasStatus Response> +void process_status(Response* response) { + if (auto status = Status::create(response->status()); !status) { + LOG(WARNING) << "RPC meet error status: " << status; + } +} + template <typename Request, typename Callback> class AutoReleaseClosure : public google::protobuf::Closure { using Weak = typename std::shared_ptr<Callback>::weak_type; @@ -91,6 +104,11 @@ public: if (auto tmp = callback_.lock()) { tmp->call(); } + if (cntl_->Failed()) { + LOG(WARNING) << "RPC meet failed: " << cntl_->ErrorText(); + } else { + process_status<ResponseType>(response_.get()); + } } // controller has to be the same lifecycle with the closure, because brpc may use --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
