yangzhg commented on a change in pull request #6916: URL: https://github.com/apache/incubator-doris/pull/6916#discussion_r739921631
########## File path: be/src/util/brpc_stub_cache.h ########## @@ -34,25 +34,32 @@ class BrpcStubCache { BrpcStubCache(); virtual ~BrpcStubCache(); - virtual PBackendService_Stub* get_stub(const butil::EndPoint& endpoint) { - std::lock_guard<SpinLock> l(_lock); + virtual std::shared_ptr<PBackendService_Stub> get_stub(const butil::EndPoint& endpoint) { + std::lock_guard<std::mutex> l(_mutex); auto stub_ptr = _stub_map.seek(endpoint); if (stub_ptr != nullptr) { - return *stub_ptr; + if (available(*stub_ptr, endpoint)) { Review comment: Checking availability is a low-cost check. Checking and refreshing before obtaining the stub is more appropriate than handling it after failure. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org