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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]