Skip to content

Commit 14723c6

Browse files
authored
[enhancement](thriftconnection) change default timeout when user not set (#49691)
1 parent 6c147bb commit 14723c6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

be/src/runtime/client_cache.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,13 @@ Status ClientCacheHelper::_create_client(const TNetworkAddress& hostport,
122122
}
123123

124124
DCHECK(*client_key != nullptr);
125-
client_impl->set_send_timeout(timeout_ms);
126-
client_impl->set_recv_timeout(timeout_ms);
125+
// In thrift, timeout == 0, means wait infinitely, so that it should not happen.
126+
// See https://github.com/apache/thrift/blob/master/lib/cpp/src/thrift/transport/TSocket.cpp.
127+
// There is some code like this: int ret = THRIFT_POLL(fds, 2, (recvTimeout_ == 0) ? -1 : recvTimeout_);
128+
// If the developer missed to set the timeout, we should use default timeout, not infinitely.
129+
// See https://linux.die.net/man/2/poll. Specifying a negative value in timeout means an infinite timeout.
130+
client_impl->set_send_timeout(timeout_ms == 0 ? config::thrift_rpc_timeout_ms : timeout_ms);
131+
client_impl->set_recv_timeout(timeout_ms == 0 ? config::thrift_rpc_timeout_ms : timeout_ms);
127132

128133
{
129134
std::lock_guard<std::mutex> lock(_lock);

0 commit comments

Comments
 (0)