Commit 32e12b6
committed
[yugabyte#9016] YSQL: Avoid timestamp overflow in the ConcurrentPod::Load method
Summary:
The following error in asan test shows that `ConcurrentPod::Load` may cause timestamp overflow in case of using large (i.e. MonoDelta::kMax) timeouts.
Logs:
```
/opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20210611151621-82ad1fb3bb-centos7-clang7/installed/asan/libcxx/include/c++/v1/chrono:1205:35: runtime error: signed integer overflow: 2023109119671 + 9223372036854000000 cannot be represented in type 'long long'
#0 0x7f355b328304 in std::__1::common_type<std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >::type std::__1::chrono::operator+<long long, std::__1::ratio<1l, 1000000000l>, long long, std::__1::ratio<1l, 1000000000l> >(std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20210611151621-82ad1fb3bb-centos7-clang7/installed/asan/libcxx/include/c++/v1/chrono:1205:35
#1 0x7f355b328304 in std::__1::chrono::time_point<yb::CoarseMonoClock, std::__1::common_type<std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > >::type> std::__1::chrono::operator+<yb::CoarseMonoClock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> >, long long, std::__1::ratio<1l, 1000000000l> >(std::__1::chrono::time_point<yb::CoarseMonoClock, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > > const&, std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000000l> > const&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20210611151621-82ad1fb3bb-centos7-clang7/installed/asan/libcxx/include/c++/v1/chrono:1504
#2 0x7f355b328304 in yb::ConcurrentPod<boost::asio::ip::basic_endpoint<boost::asio::ip::tcp> >::Load() const $BUILD_ROOT/../../src/yb/util/concurrent_pod.h:42
#3 0x7f355b32270f in yb::rpc::Proxy::DoAsyncRequest(yb::rpc::RemoteMethod const*, google::protobuf::Message const&, google::protobuf::Message*, yb::rpc::RpcController*, std::__1::function<void ()>, bool) $BUILD_ROOT/../../src/yb/rpc/proxy.cc:200:28
#4 0x7f355b321d06 in yb::rpc::Proxy::AsyncRequest(yb::rpc::RemoteMethod const*, google::protobuf::Message const&, google::protobuf::Message*, yb::rpc::RpcController*, std::__1::function<void ()>) $BUILD_ROOT/../../src/yb/rpc/proxy.cc:123:3
#5 0x7f355d0070e8 in yb::tserver::TabletServerServiceProxy::UpdateTransactionAsync(yb::tserver::UpdateTransactionRequestPB const&, yb::tserver::UpdateTransactionResponsePB*, yb::rpc::RpcController*, std::__1::function<void ()>) $BUILD_ROOT/src/yb/tserver/tserver_service.proxy.cc:137:11
#6 0x7f3560f6ec8e in yb::client::(anonymous namespace)::UpdateTransactionTraits::InvokeAsync(yb::tserver::TabletServerServiceProxy*, yb::tserver::UpdateTransactionRequestPB*, yb::tserver::UpdateTransactionResponsePB*, yb::rpc::RpcController*, std::__1::function<void ()>) $BUILD_ROOT/../../src/yb/client/transaction_rpc.cc:181:1
#7 0x7f3560f6e0cf in yb::client::(anonymous namespace)::TransactionRpc<yb::client::(anonymous namespace)::UpdateTransactionTraits>::InvokeAsync(yb::tserver::TabletServerServiceProxy*, yb::rpc::RpcController*, std::__1::function<void ()>) $BUILD_ROOT/../../src/yb/client/transaction_rpc.cc:128:5
#8 0x7f3560f6de08 in yb::client::(anonymous namespace)::TransactionRpcBase::SendRpcToTserver(int) $BUILD_ROOT/../../src/yb/client/transaction_rpc.cc:77:5
...
```
To avoid overflow even with large timeout condition
```
CoarseMonoClock::now() > time1 + timeout_
```
is substituted with
```
CoarseMonoClock::now() - time1 > timeout_
```
Test Plan:
Run existed test
```
./yb_build.sh --clang7 asan --java-test org.yb.pgsql.TestSecureClusterLocalTServerHostName
```
Reviewers: alex, mihnea, sergei
Reviewed By: sergei
Subscribers: yql
Differential Revision: https://phabricator.dev.yugabyte.com/D121821 parent 9d3fa52 commit 32e12b6
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
0 commit comments