Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DocDB] PgTableSizeTest_PartitionedTableSize fails on TSAN build due to function yb::client::YBSubTransaction::active() #15930

Open
deeps1991 opened this issue Feb 1, 2023 · 2 comments
Assignees
Labels
area/docdb YugabyteDB core features kind/bug This issue is a bug kind/failing-test Tests and testing infra priority/medium Medium priority issue

Comments

@deeps1991
Copy link
Contributor

deeps1991 commented Feb 1, 2023

Jira Link: DB-5343

Description

WARNING: ThreadSanitizer: data race (pid=27015)
  Read of size 4 at 0x7b5c000846c0 by thread T197:
    #0 yb::client::YBSubTransaction::active() const ${BUILD_ROOT}/../../src/yb/client/transaction.h:165:12 (libyb_client.so+0x434283)
    #1 yb::client::YBTransaction::Impl::Prepare(yb::client::internal::InFlightOpsGroupsWithMetadata*, yb::StronglyTypedBool<yb::client::ForceConsistentRead_Tag>, std::chrono::time_point<yb::CoarseMonoClock, std::chrono::duration<long long, std::ratio<1l, 1000000000l>>>, yb::StronglyTypedBool<yb::client::Initial_Tag>, boost::function<void (yb::Status const&)>) ${BUILD_ROOT}/../../src/yb/client/transaction.cc:370:43 (libyb_client.so+0x434283)
    #2 yb::client::internal::Batcher::ExecuteOperations(yb::StronglyTypedBool<yb::client::Initial_Tag>) ${BUILD_ROOT}/../../src/yb/client/batcher.cc:520:36 (libyb_client.so+0x2bc9f1)
    #3 yb::client::internal::Batcher::AllLookupsDone() ${BUILD_ROOT}/../../src/yb/client/batcher.cc:508:3 (libyb_client.so+0x2bc3a4)
    #4 yb::client::internal::Batcher::TabletLookupFinished(yb::client::internal::InFlightOp*, yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>>) ${BUILD_ROOT}/../../src/yb/client/batcher.cc:345:5 (libyb_client.so+0x2baf03)
    #5 auto yb::client::internal::Batcher::LookupTabletFor(yb::client::internal::InFlightOp*)::$_0::operator()<yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>>>(yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&) const ${BUILD_ROOT}/../../src/yb/client/batcher.cc:321:22 (libyb_client.so+0x2c39b3)
    #6 decltype(std::declval<yb::client::internal::Batcher::LookupTabletFor(yb::client::internal::InFlightOp*)::$_0&>()(std::declval<yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&>())) std::__invoke[abi:v15003]<yb::client::internal::Batcher::LookupTabletFor(yb::client::internal::InFlightOp*)::$_0&, yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&>(yb::client::internal::Batcher::LookupTabletFor(yb::client::internal::InFlightOp*)::$_0&, yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/invoke.h:394:23 (libyb_client.so+0x2c39b3)
    #7 void std::__invoke_void_return_wrapper<void, true>::__call<yb::client::internal::Batcher::LookupTabletFor(yb::client::internal::InFlightOp*)::$_0&, yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&>(yb::client::internal::Batcher::LookupTabletFor(yb::client::internal::InFlightOp*)::$_0&, yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/invoke.h:479:9 (libyb_client.so+0x2c39b3)
    #8 std::__function::__alloc_func<yb::client::internal::Batcher::LookupTabletFor(yb::client::internal::InFlightOp*)::$_0, std::allocator<yb::client::internal::Batcher::LookupTabletFor(yb::client::internal::InFlightOp*)::$_0>, void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)>::operator()[abi:v15003](yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:185:16 (libyb_client.so+0x2c39b3)
    #9 std::__function::__func<yb::client::internal::Batcher::LookupTabletFor(yb::client::internal::InFlightOp*)::$_0, std::allocator<yb::client::internal::Batcher::LookupTabletFor(yb::client::internal::InFlightOp*)::$_0>, void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)>::operator()(yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:359:12 (libyb_client.so+0x2c39b3)
    #10 std::__function::__value_func<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)>::operator()[abi:v15003](yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&) const /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:512:16 (libyb_client.so+0x3b0eb5)
    #11 std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)>::operator()(yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&) const /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:1197:12 (libyb_client.so+0x3b0eb5)
    #12 yb::client::internal::LookupCallbackVisitor::operator()(std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)> const&) const ${BUILD_ROOT}/../../src/yb/client/meta_cache.cc:657:3 (libyb_client.so+0x3b0eb5)
    #13 boost::disable_if_c<false && is_same<std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)> const&, std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)> const&>::value, void>::type boost::detail::variant::invoke_visitor<yb::client::internal::LookupCallbackVisitor const, false>::internal_visit<std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)> const&>(std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)> const&, int) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/include/boost/variant/variant.hpp:1028:16 (libyb_client.so+0x3d246a)
    #14 boost::detail::variant::invoke_visitor<yb::client::internal::LookupCallbackVisitor const, false>::result_type boost::detail::variant::visitation_impl_invoke_impl<boost::detail::variant::invoke_visitor<yb::client::internal::LookupCallbackVisitor const, false>, void const*, std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)>>(int, boost::detail::variant::invoke_visitor<yb::client::internal::LookupCallbackVisitor const, false>&, void const*, std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)>*, mpl_::bool_<true>) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/include/boost/variant/detail/visitation_impl.hpp:117:20 (libyb_client.so+0x3d246a)
    #15 boost::detail::variant::invoke_visitor<yb::client::internal::LookupCallbackVisitor const, false>::result_type boost::detail::variant::visitation_impl_invoke<boost::detail::variant::invoke_visitor<yb::client::internal::LookupCallbackVisitor const, false>, void const*, std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)>, boost::variant<std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)>, std::function<void (yb::Result<std::vector<scoped_refptr<yb::client::internal::RemoteTablet>, std::allocator<scoped_refptr<yb::client::internal::RemoteTablet>>>> const&)>>::has_fallback_type_>(int, boost::detail::variant::invoke_visitor<yb::client::internal::LookupCallbackVisitor const, false>&, void const*, std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)>*, boost::variant<std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)>, std::function<void (yb::Result<std::vector<scoped_refptr<yb::client::internal::RemoteTablet>, std::allocator<scoped_refptr<yb::client::internal::RemoteTablet>>>> const&)>>::has_fallback_type_, int) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/include/boost/variant/detail/visitation_impl.hpp:157:12 (libyb_client.so+0x3d246a)
    #16 boost::detail::variant::invoke_visitor<yb::client::internal::LookupCallbackVisitor const, false>::result_type boost::detail::variant::visitation_impl<mpl_::int_<0>, boost::detail::variant::visitation_impl_step<boost::mpl::l_iter<boost::mpl::l_item<mpl_::long_<2l>, std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)>, boost::mpl::l_item<mpl_::long_<1l>, std::function<void (yb::Result<std::vector<scoped_refptr<yb::client::internal::RemoteTablet>, std::allocator<scoped_refptr<yb::client::internal::RemoteTablet>>>> const&)>, boost::mpl::l_end>>>, boost::mpl::l_iter<boost::mpl::l_end>>, boost::detail::variant::invoke_visitor<yb::client::internal::LookupCallbackVisitor const, false>, void const*, boost::variant<std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)>, std::function<void (yb::Result<std::vector<scoped_refptr<yb::client::internal::RemoteTablet>, std::allocator<scoped_refptr<yb::client::internal::RemoteTablet>>>> const&)>>::has_fallback_type_>(int, int, boost::detail::variant::invoke_visitor<yb::client::internal::LookupCallbackVisitor const, false>&, void const*, mpl_::bool_<false>, boost::variant<std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)>, std::function<void (yb::Result<std::vector<scoped_refptr<yb::client::internal::RemoteTablet>, std::allocator<scoped_refptr<yb::client::internal::RemoteTablet>>>> const&)>>::has_fallback_type_, mpl_::int_<0>*, boost::detail::variant::visitation_impl_step<boost::mpl::l_iter<boost::mpl::l_item<mpl_::long_<2l>, std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)>, boost::mpl::l_item<mpl_::long_<1l>, std::function<void (yb::Result<std::vector<scoped_refptr<yb::client::internal::RemoteTablet>, std::allocator<scoped_refptr<yb::client::internal::RemoteTablet>>>> const&)>, boost::mpl::l_end>>>, boost::mpl::l_iter<boost::mpl::l_end>>*) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/include/boost/variant/detail/visitation_impl.hpp:238:5 (libyb_client.so+0x3d246a)
    #17 boost::detail::variant::invoke_visitor<yb::client::internal::LookupCallbackVisitor const, false>::result_type boost::variant<std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)>, std::function<void (yb::Result<std::vector<scoped_refptr<yb::client::internal::RemoteTablet>, std::allocator<scoped_refptr<yb::client::internal::RemoteTablet>>>> const&)>>::internal_apply_visitor_impl<boost::detail::variant::invoke_visitor<yb::client::internal::LookupCallbackVisitor const, false>, void const*>(int, int, boost::detail::variant::invoke_visitor<yb::client::internal::LookupCallbackVisitor const, false>&, void const*) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/include/boost/variant/variant.hpp:2337:16 (libyb_client.so+0x3d246a)
    #18 boost::detail::variant::invoke_visitor<yb::client::internal::LookupCallbackVisitor const, false>::result_type boost::variant<std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)>, std::function<void (yb::Result<std::vector<scoped_refptr<yb::client::internal::RemoteTablet>, std::allocator<scoped_refptr<yb::client::internal::RemoteTablet>>>> const&)>>::internal_apply_visitor<boost::detail::variant::invoke_visitor<yb::client::internal::LookupCallbackVisitor const, false>>(boost::detail::variant::invoke_visitor<yb::client::internal::LookupCallbackVisitor const, false>&) const /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/include/boost/variant/variant.hpp:2358:16 (libyb_client.so+0x3d246a)
    #19 yb::client::internal::LookupCallbackVisitor const::result_type boost::variant<std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)>, std::function<void (yb::Result<std::vector<scoped_refptr<yb::client::internal::RemoteTablet>, std::allocator<scoped_refptr<yb::client::internal::RemoteTablet>>>> const&)>>::apply_visitor<yb::client::internal::LookupCallbackVisitor const>(yb::client::internal::LookupCallbackVisitor const&) const & /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/include/boost/variant/variant.hpp:2404:22 (libyb_client.so+0x3d246a)
    #20 yb::client::internal::LookupCallbackVisitor::result_type boost::apply_visitor<yb::client::internal::LookupCallbackVisitor, boost::variant<std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)>, std::function<void (yb::Result<std::vector<scoped_refptr<yb::client::internal::RemoteTablet>, std::allocator<scoped_refptr<yb::client::internal::RemoteTablet>>>> const&)>> const&>(yb::client::internal::LookupCallbackVisitor const&, boost::variant<std::function<void (yb::Result<scoped_refptr<yb::client::internal::RemoteTablet>> const&)>, std::function<void (yb::Result<std::vector<scoped_refptr<yb::client::internal::RemoteTablet>, std::allocator<scoped_refptr<yb::client::internal::RemoteTablet>>>> const&)>> const&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/include/boost/variant/detail/apply_visitor_unary.hpp:68:51 (libyb_client.so+0x3b3b4b)
    #21 yb::client::internal::MetaCache::ProcessTabletLocations(google::protobuf::RepeatedPtrField<yb::master::TabletLocationsPB> const&, boost::optional<unsigned int>, yb::client::internal::LookupRpc*) ${BUILD_ROOT}/../../src/yb/client/meta_cache.cc:972:5 (libyb_client.so+0x3b3b4b)
    #22 yb::client::internal::LookupByKeyRpc::ProcessTabletLocations(google::protobuf::RepeatedPtrField<yb::master::TabletLocationsPB> const&, boost::optional<unsigned int>) ${BUILD_ROOT}/../../src/yb/client/meta_cache.cc:1606:26 (libyb_client.so+0x3d94ee)
    #23 void yb::client::internal::LookupRpc::DoProcessResponse<yb::master::GetTableLocationsResponsePB>(yb::Status const&, yb::master::GetTableLocationsResponsePB const&) ${BUILD_ROOT}/../../src/yb/client/meta_cache.cc:855:18 (libyb_client.so+0x3db2b1)
    #24 yb::client::internal::LookupByKeyRpc::ProcessResponse(yb::Status const&) ${BUILD_ROOT}/../../src/yb/client/meta_cache.cc:1532:5 (libyb_client.so+0x3d82c7)
    #25 yb::client::internal::ClientMasterRpcBase::Finished(yb::Status const&) ${BUILD_ROOT}/../../src/yb/client/client_master_rpc.cc:157:3 (libyb_client.so+0x2fcdda)
    #26 decltype(*std::declval<yb::client::internal::LookupByKeyRpc*&>().*std::declval<void (yb::client::internal::ClientMasterRpcBase::*&)(yb::Status const&)>()(std::declval<yb::Status::OK&>())) std::__invoke[abi:v15003]<void (yb::client::internal::ClientMasterRpcBase::*&)(yb::Status const&), yb::client::internal::LookupByKeyRpc*&, yb::Status::OK&, void>(void (yb::client::internal::ClientMasterRpcBase::*&)(yb::Status const&), yb::client::internal::LookupByKeyRpc*&, yb::Status::OK&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/invoke.h:359:23 (libyb_client.so+0x3da92d)
    #27 std::__bind_return<void (yb::client::internal::ClientMasterRpcBase::*)(yb::Status const&), std::tuple<yb::client::internal::LookupByKeyRpc*, yb::Status::OK>, std::tuple<>, __is_valid_bind_return<void (yb::client::internal::ClientMasterRpcBase::*)(yb::Status const&), std::tuple<yb::client::internal::LookupByKeyRpc*, yb::Status::OK>, std::tuple<>>::value>::type std::__apply_functor[abi:v15003]<void (yb::client::internal::ClientMasterRpcBase::*)(yb::Status const&), std::tuple<yb::client::internal::LookupByKeyRpc*, yb::Status::OK>, 0ul, 1ul, std::tuple<>>(void (yb::client::internal::ClientMasterRpcBase::*&)(yb::Status const&), std::tuple<yb::client::internal::LookupByKeyRpc*, yb::Status::OK>&, std::__tuple_indices<0ul, 1ul>, std::tuple<>&&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/bind.h:263:12 (libyb_client.so+0x3da92d)
    #28 std::__bind_return<void (yb::client::internal::ClientMasterRpcBase::*)(yb::Status const&), std::tuple<yb::client::internal::LookupByKeyRpc*, yb::Status::OK>, std::tuple<>, __is_valid_bind_return<void (yb::client::internal::ClientMasterRpcBase::*)(yb::Status const&), std::tuple<yb::client::internal::LookupByKeyRpc*, yb::Status::OK>, std::tuple<>>::value>::type std::__bind<void (yb::client::internal::ClientMasterRpcBase::*)(yb::Status const&), yb::client::internal::LookupByKeyRpc*, yb::Status::OK>::operator()[abi:v15003]<>() /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/bind.h:295:20 (libyb_client.so+0x3da92d)
    #29 decltype(std::declval<std::__bind<void (yb::client::internal::ClientMasterRpcBase::*)(yb::Status const&), yb::client::internal::LookupByKeyRpc*, yb::Status::OK>&>()()) std::__invoke[abi:v15003]<std::__bind<void (yb::client::internal::ClientMasterRpcBase::*)(yb::Status const&), yb::client::internal::LookupByKeyRpc*, yb::Status::OK>&>(std::__bind<void (yb::client::internal::ClientMasterRpcBase::*)(yb::Status const&), yb::client::internal::LookupByKeyRpc*, yb::Status::OK>&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/invoke.h:394:23 (libyb_client.so+0x3da83d)
    #30 void std::__invoke_void_return_wrapper<void, true>::__call<std::__bind<void (yb::client::internal::ClientMasterRpcBase::*)(yb::Status const&), yb::client::internal::LookupByKeyRpc*, yb::Status::OK>&>(std::__bind<void (yb::client::internal::ClientMasterRpcBase::*)(yb::Status const&), yb::client::internal::LookupByKeyRpc*, yb::Status::OK>&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/invoke.h:479:9 (libyb_client.so+0x3da83d)
    #31 std::__function::__alloc_func<std::__bind<void (yb::client::internal::ClientMasterRpcBase::*)(yb::Status const&), yb::client::internal::LookupByKeyRpc*, yb::Status::OK>, std::allocator<std::__bind<void (yb::client::internal::ClientMasterRpcBase::*)(yb::Status const&), yb::client::internal::LookupByKeyRpc*, yb::Status::OK>>, void ()>::operator()[abi:v15003]() /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:185:16 (libyb_client.so+0x3da83d)
    #32 std::__function::__func<std::__bind<void (yb::client::internal::ClientMasterRpcBase::*)(yb::Status const&), yb::client::internal::LookupByKeyRpc*, yb::Status::OK>, std::allocator<std::__bind<void (yb::client::internal::ClientMasterRpcBase::*)(yb::Status const&), yb::client::internal::LookupByKeyRpc*, yb::Status::OK>>, void ()>::operator()() /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:359:12 (libyb_client.so+0x3da83d)
    #33 std::__function::__value_func<void ()>::operator()[abi:v15003]() const /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:512:16 (libyrpc.so+0x103073)
    #34 std::function<void ()>::operator()() const /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:1197:12 (libyrpc.so+0x103073)
    #35 yb::rpc::OutboundCall::InvokeCallbackSync() ${BUILD_ROOT}/../../src/yb/rpc/outbound_call.cc:352:3 (libyrpc.so+0x103073)
    #36 yb::rpc::InvokeCallbackTask::Run() ${BUILD_ROOT}/../../src/yb/rpc/outbound_call.cc:126:10 (libyrpc.so+0x102f8d)
    #37 yb::rpc::(anonymous namespace)::Worker::Execute() ${BUILD_ROOT}/../../src/yb/rpc/thread_pool.cc:104:15 (libyrpc.so+0x191564)
    #38 decltype(*std::declval<yb::rpc::(anonymous namespace)::Worker*&>().*std::declval<void (yb::rpc::(anonymous namespace)::Worker::*&)()>()()) std::__invoke[abi:v15003]<void (yb::rpc::(anonymous namespace)::Worker::*&)(), yb::rpc::(anonymous namespace)::Worker*&, void>(void (yb::rpc::(anonymous namespace)::Worker::*&)(), yb::rpc::(anonymous namespace)::Worker*&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/invoke.h:359:23 (libyrpc.so+0x1919cb)
    #39 std::__bind_return<void (yb::rpc::(anonymous namespace)::Worker::*)(), std::tuple<yb::rpc::(anonymous namespace)::Worker*>, std::tuple<>, __is_valid_bind_return<void (yb::rpc::(anonymous namespace)::Worker::*)(), std::tuple<yb::rpc::(anonymous namespace)::Worker*>, std::tuple<>>::value>::type std::__apply_functor[abi:v15003]<void (yb::rpc::(anonymous namespace)::Worker::*)(), std::tuple<yb::rpc::(anonymous namespace)::Worker*>, 0ul, std::tuple<>>(void (yb::rpc::(anonymous namespace)::Worker::*&)(), std::tuple<yb::rpc::(anonymous namespace)::Worker*>&, std::__tuple_indices<0ul>, std::tuple<>&&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/bind.h:263:12 (libyrpc.so+0x1919cb)
    #40 std::__bind_return<void (yb::rpc::(anonymous namespace)::Worker::*)(), std::tuple<yb::rpc::(anonymous namespace)::Worker*>, std::tuple<>, __is_valid_bind_return<void (yb::rpc::(anonymous namespace)::Worker::*)(), std::tuple<yb::rpc::(anonymous namespace)::Worker*>, std::tuple<>>::value>::type std::__bind<void (yb::rpc::(anonymous namespace)::Worker::* const&)(), yb::rpc::(anonymous namespace)::Worker* const&>::operator()[abi:v15003]<>() /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/bind.h:295:20 (libyrpc.so+0x1919cb)
    #41 decltype(std::declval<std::__bind<void (yb::rpc::(anonymous namespace)::Worker::* const&)(), yb::rpc::(anonymous namespace)::Worker* const&>&>()()) std::__invoke[abi:v15003]<std::__bind<void (yb::rpc::(anonymous namespace)::Worker::* const&)(), yb::rpc::(anonymous namespace)::Worker* const&>&>(std::__bind<void (yb::rpc::(anonymous namespace)::Worker::* const&)(), yb::rpc::(anonymous namespace)::Worker* const&>&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/invoke.h:394:23 (libyrpc.so+0x1919cb)
    #42 void std::__invoke_void_return_wrapper<void, true>::__call<std::__bind<void (yb::rpc::(anonymous namespace)::Worker::* const&)(), yb::rpc::(anonymous namespace)::Worker* const&>&>(std::__bind<void (yb::rpc::(anonymous namespace)::Worker::* const&)(), yb::rpc::(anonymous namespace)::Worker* const&>&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/invoke.h:479:9 (libyrpc.so+0x1919cb)
    #43 std::__function::__alloc_func<std::__bind<void (yb::rpc::(anonymous namespace)::Worker::* const&)(), yb::rpc::(anonymous namespace)::Worker* const&>, std::allocator<std::__bind<void (yb::rpc::(anonymous namespace)::Worker::* const&)(), yb::rpc::(anonymous namespace)::Worker* const&>>, void ()>::operator()[abi:v15003]() /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:185:16 (libyrpc.so+0x1919cb)
    #44 std::__function::__func<std::__bind<void (yb::rpc::(anonymous namespace)::Worker::* const&)(), yb::rpc::(anonymous namespace)::Worker* const&>, std::allocator<std::__bind<void (yb::rpc::(anonymous namespace)::Worker::* const&)(), yb::rpc::(anonymous namespace)::Worker* const&>>, void ()>::operator()() /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:359:12 (libyrpc.so+0x1919cb)
    #45 std::__function::__value_func<void ()>::operator()[abi:v15003]() const /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:512:16 (libyb_util.so+0x354e64)
    #46 std::function<void ()>::operator()() const /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:1197:12 (libyb_util.so+0x354e64)
    #47 yb::Thread::SuperviseThread(void*) ${BUILD_ROOT}/../../src/yb/util/thread.cc:800:3 (libyb_util.so+0x354e64)

  Previous write of size 4 at 0x7b5c000846c0 by thread T249 (mutexes: write M0):
    #0 yb::client::YBSubTransaction::SetActiveSubTransaction(unsigned int) ${BUILD_ROOT}/../../src/yb/client/transaction.cc:138:30 (libyb_client.so+0x42fa41)
    #1 yb::client::YBTransaction::Impl::SetActiveSubTransaction(unsigned int) ${BUILD_ROOT}/../../src/yb/client/transaction.cc:832:28 (libyb_client.so+0x42fa41)
    #2 yb::client::YBTransaction::SetActiveSubTransaction(unsigned int) ${BUILD_ROOT}/../../src/yb/client/transaction.cc:2149:17 (libyb_client.so+0x42535a)
    #3 yb::tserver::PgClientSession::SetupSession(yb::tserver::PgPerformRequestPB const&, std::chrono::time_point<yb::CoarseMonoClock, std::chrono::duration<long long, std::ratio<1l, 1000000000l>>>) ${BUILD_ROOT}/../../src/yb/tserver/pg_client_session.cc:863:18 (libtserver.so+0x1833c6)
    #4 yb::tserver::PgClientSession::Perform(yb::tserver::PgPerformRequestPB*, yb::tserver::PgPerformResponsePB*, yb::rpc::RpcContext*) ${BUILD_ROOT}/../../src/yb/tserver/pg_client_session.cc:702:23 (libtserver.so+0x180810)
    #5 yb::tserver::PgClientServiceImpl::Impl::DoPerform(yb::tserver::PgPerformRequestPB*, yb::tserver::PgPerformResponsePB*, yb::rpc::RpcContext*) ${BUILD_ROOT}/../../src/yb/tserver/pg_client_service.cc:475:45 (libtserver.so+0x17955e)
    #6 yb::tserver::PgClientServiceImpl::Impl::Perform(yb::tserver::PgPerformRequestPB*, yb::tserver::PgPerformResponsePB*, yb::rpc::RpcContext*) ${BUILD_ROOT}/../../src/yb/tserver/pg_client_service.cc:396:19 (libtserver.so+0x171d48)
    #7 yb::tserver::PgClientServiceImpl::Perform(yb::tserver::PgPerformRequestPB const*, yb::tserver::PgPerformResponsePB*, yb::rpc::RpcContext) ${BUILD_ROOT}/../../src/yb/tserver/pg_client_service.cc:537:10 (libtserver.so+0x16e6e0)
    #8 yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17::operator()(std::shared_ptr<yb::rpc::InboundCall>) const::'lambda'(yb::tserver::PgPerformRequestPB const*, yb::tserver::PgPerformResponsePB*, yb::rpc::RpcContext)::operator()(yb::tserver::PgPerformRequestPB const*, yb::tserver::PgPerformResponsePB*, yb::rpc::RpcContext) const ${BUILD_ROOT}/src/yb/tserver/pg_client.service.cc:943:9 (libpg_client_proto.so+0x1a51ba)
    #9 auto yb::rpc::HandleCall<yb::rpc::RpcCallPBParamsImpl<yb::tserver::PgPerformRequestPB, yb::tserver::PgPerformResponsePB>, yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17::operator()(std::shared_ptr<yb::rpc::InboundCall>) const::'lambda'(yb::tserver::PgPerformRequestPB const*, yb::tserver::PgPerformResponsePB*, yb::rpc::RpcContext)>(std::shared_ptr<yb::rpc::InboundCall>, yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17::operator()(std::shared_ptr<yb::rpc::InboundCall>) const::'lambda'(yb::tserver::PgPerformRequestPB const*, yb::tserver::PgPerformResponsePB*, yb::rpc::RpcContext)) ${BUILD_ROOT}/../../src/yb/rpc/local_call.h:115:7 (libpg_client_proto.so+0x1a51ba)
    #10 yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17::operator()(std::shared_ptr<yb::rpc::InboundCall>) const ${BUILD_ROOT}/src/yb/tserver/pg_client.service.cc:941:7 (libpg_client_proto.so+0x1a51ba)
    #11 decltype(std::declval<yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17&>()(std::declval<std::shared_ptr<yb::rpc::InboundCall>>())) std::__invoke[abi:v15003]<yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17&, std::shared_ptr<yb::rpc::InboundCall>>(yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17&, std::shared_ptr<yb::rpc::InboundCall>&&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/invoke.h:394:23 (libpg_client_proto.so+0x1a51ba)
    #12 void std::__invoke_void_return_wrapper<void, true>::__call<yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17&, std::shared_ptr<yb::rpc::InboundCall>>(yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17&, std::shared_ptr<yb::rpc::InboundCall>&&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/invoke.h:479:9 (libpg_client_proto.so+0x1a51ba)
    #13 std::__function::__alloc_func<yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17, std::allocator<yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17>, void (std::shared_ptr<yb::rpc::InboundCall>)>::operator()[abi:v15003](std::shared_ptr<yb::rpc::InboundCall>&&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:185:16 (libpg_client_proto.so+0x1a51ba)
    #14 std::__function::__func<yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17, std::allocator<yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17>, void (std::shared_ptr<yb::rpc::InboundCall>)>::operator()(std::shared_ptr<yb::rpc::InboundCall>&&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:359:12 (libpg_client_proto.so+0x1a51ba)
    #15 std::__function::__value_func<void (std::shared_ptr<yb::rpc::InboundCall>)>::operator()[abi:v15003](std::shared_ptr<yb::rpc::InboundCall>&&) const /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:512:16 (libpg_client_proto.so+0x198f82)
    #16 std::function<void (std::shared_ptr<yb::rpc::InboundCall>)>::operator()(std::shared_ptr<yb::rpc::InboundCall>) const /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:1197:12 (libpg_client_proto.so+0x198f82)
    #17 yb::tserver::PgClientServiceIf::Handle(std::shared_ptr<yb::rpc::InboundCall>) ${BUILD_ROOT}/src/yb/tserver/pg_client.service.cc:671:3 (libpg_client_proto.so+0x198f82)
    #18 yb::rpc::ServicePoolImpl::Handle(std::shared_ptr<yb::rpc::InboundCall>) ${BUILD_ROOT}/../../src/yb/rpc/service_pool.cc:263:19 (libyrpc.so+0x17abba)
    #19 yb::rpc::InboundCall::InboundCallTask::Run() ${BUILD_ROOT}/../../src/yb/rpc/inbound_call.cc:236:13 (libyrpc.so+0xe72c9)
    #20 yb::rpc::(anonymous namespace)::Worker::Execute() ${BUILD_ROOT}/../../src/yb/rpc/thread_pool.cc:104:15 (libyrpc.so+0x191564)
    #21 decltype(*std::declval<yb::rpc::(anonymous namespace)::Worker*&>().*std::declval<void (yb::rpc::(anonymous namespace)::Worker::*&)()>()()) std::__invoke[abi:v15003]<void (yb::rpc::(anonymous namespace)::Worker::*&)(), yb::rpc::(anonymous namespace)::Worker*&, void>(void (yb::rpc::(anonymous namespace)::Worker::*&)(), yb::rpc::(anonymous namespace)::Worker*&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/invoke.h:359:23 (libyrpc.so+0x1919cb)
    #22 std::__bind_return<void (yb::rpc::(anonymous namespace)::Worker::*)(), std::tuple<yb::rpc::(anonymous namespace)::Worker*>, std::tuple<>, __is_valid_bind_return<void (yb::rpc::(anonymous namespace)::Worker::*)(), std::tuple<yb::rpc::(anonymous namespace)::Worker*>, std::tuple<>>::value>::type std::__apply_functor[abi:v15003]<void (yb::rpc::(anonymous namespace)::Worker::*)(), std::tuple<yb::rpc::(anonymous namespace)::Worker*>, 0ul, std::tuple<>>(void (yb::rpc::(anonymous namespace)::Worker::*&)(), std::tuple<yb::rpc::(anonymous namespace)::Worker*>&, std::__tuple_indices<0ul>, std::tuple<>&&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/bind.h:263:12 (libyrpc.so+0x1919cb)
    #23 std::__bind_return<void (yb::rpc::(anonymous namespace)::Worker::*)(), std::tuple<yb::rpc::(anonymous namespace)::Worker*>, std::tuple<>, __is_valid_bind_return<void (yb::rpc::(anonymous namespace)::Worker::*)(), std::tuple<yb::rpc::(anonymous namespace)::Worker*>, std::tuple<>>::value>::type std::__bind<void (yb::rpc::(anonymous namespace)::Worker::* const&)(), yb::rpc::(anonymous namespace)::Worker* const&>::operator()[abi:v15003]<>() /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/bind.h:295:20 (libyrpc.so+0x1919cb)
    #24 decltype(std::declval<std::__bind<void (yb::rpc::(anonymous namespace)::Worker::* const&)(), yb::rpc::(anonymous namespace)::Worker* const&>&>()()) std::__invoke[abi:v15003]<std::__bind<void (yb::rpc::(anonymous namespace)::Worker::* const&)(), yb::rpc::(anonymous namespace)::Worker* const&>&>(std::__bind<void (yb::rpc::(anonymous namespace)::Worker::* const&)(), yb::rpc::(anonymous namespace)::Worker* const&>&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/invoke.h:394:23 (libyrpc.so+0x1919cb)
    #25 void std::__invoke_void_return_wrapper<void, true>::__call<std::__bind<void (yb::rpc::(anonymous namespace)::Worker::* const&)(), yb::rpc::(anonymous namespace)::Worker* const&>&>(std::__bind<void (yb::rpc::(anonymous namespace)::Worker::* const&)(), yb::rpc::(anonymous namespace)::Worker* const&>&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/invoke.h:479:9 (libyrpc.so+0x1919cb)
    #26 std::__function::__alloc_func<std::__bind<void (yb::rpc::(anonymous namespace)::Worker::* const&)(), yb::rpc::(anonymous namespace)::Worker* const&>, std::allocator<std::__bind<void (yb::rpc::(anonymous namespace)::Worker::* const&)(), yb::rpc::(anonymous namespace)::Worker* const&>>, void ()>::operator()[abi:v15003]() /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:185:16 (libyrpc.so+0x1919cb)
    #27 std::__function::__func<std::__bind<void (yb::rpc::(anonymous namespace)::Worker::* const&)(), yb::rpc::(anonymous namespace)::Worker* const&>, std::allocator<std::__bind<void (yb::rpc::(anonymous namespace)::Worker::* const&)(), yb::rpc::(anonymous namespace)::Worker* const&>>, void ()>::operator()() /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:359:12 (libyrpc.so+0x1919cb)
    #28 std::__function::__value_func<void ()>::operator()[abi:v15003]() const /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:512:16 (libyb_util.so+0x354e64)
    #29 std::function<void ()>::operator()() const /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:1197:12 (libyb_util.so+0x354e64)
    #30 yb::Thread::SuperviseThread(void*) ${BUILD_ROOT}/../../src/yb/util/thread.cc:800:3 (libyb_util.so+0x354e64)

  Location is heap block of size 840 at 0x7b5c00084580 allocated by thread T165:
    #0 operator new(unsigned long) /opt/yb-build/llvm/yb-llvm-v15.0.3-yb-1-1667341687-0b8d1183-centos7-x86_64-build/src/llvm-project/compiler-rt/lib/tsan/rtl/tsan_new_delete.cpp:64:3 (pg_table_size-test+0x10ebf6)
#1 yb::client::YBTransaction::YBTransaction(yb::client::TransactionManager*, yb::TransactionLocality) ${BUILD_ROOT}/../../src/yb/client/transaction.cc:2014:13 (libyb_client.so+0x4239d5)
    #2 yb::client::YBTransaction* std::construct_at[abi:v15003]<yb::client::YBTransaction, yb::client::TransactionManager*, yb::TransactionLocality&, yb::client::YBTransaction*>(yb::client::YBTransaction*, yb::client::TransactionManager*&&, yb::TransactionLocality&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__memory/construct_at.h:35:48 (libyb_client.so+0x4695bb)
    #3 void std::allocator_traits<std::allocator<yb::client::YBTransaction>>::construct[abi:v15003]<yb::client::YBTransaction, yb::client::TransactionManager*, yb::TransactionLocality&, void, void>(std::allocator<yb::client::YBTransaction>&, yb::client::YBTransaction*, yb::client::TransactionManager*&&, yb::TransactionLocality&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__memory/allocator_traits.h:298:9 (libyb_client.so+0x4695bb)
    #4 std::__shared_ptr_emplace<yb::client::YBTransaction, std::allocator<yb::client::YBTransaction>>::__shared_ptr_emplace[abi:v15003]<yb::client::TransactionManager*, yb::TransactionLocality&>(std::allocator<yb::client::YBTransaction>, yb::client::TransactionManager*&&, yb::TransactionLocality&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__memory/shared_ptr.h:292:9 (libyb_client.so+0x4695bb)
    #5 std::shared_ptr<yb::client::YBTransaction> std::allocate_shared[abi:v15003]<yb::client::YBTransaction, std::allocator<yb::client::YBTransaction>, yb::client::TransactionManager*, yb::TransactionLocality&, void>(std::allocator<yb::client::YBTransaction> const&, yb::client::TransactionManager*&&, yb::TransactionLocality&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__memory/shared_ptr.h:953:55 (libyb_client.so+0x4695bb)
    #6 std::shared_ptr<yb::client::YBTransaction> std::make_shared[abi:v15003]<yb::client::YBTransaction, yb::client::TransactionManager*, yb::TransactionLocality&, void>(yb::client::TransactionManager*&&, yb::TransactionLocality&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__memory/shared_ptr.h:962:12 (libyb_client.so+0x46739c)
    #7 yb::client::(anonymous namespace)::SingleLocalityPool::Take(std::chrono::time_point<yb::CoarseMonoClock, std::chrono::duration<long long, std::ratio<1l, 1000000000l>>>) ${BUILD_ROOT}/../../src/yb/client/transaction_pool.cc:126:17 (libyb_client.so+0x46739c)
    #8 yb::client::TransactionPool::Impl::Take(yb::StronglyTypedBool<yb::client::ForceGlobalTransaction_Tag>, std::chrono::time_point<yb::CoarseMonoClock, std::chrono::duration<long long, std::ratio<1l, 1000000000l>>>) ${BUILD_ROOT}/../../src/yb/client/transaction_pool.cc:281:68 (libyb_client.so+0x46739c)
    #9 yb::client::TransactionPool::TakeAndInit(yb::IsolationLevel, std::chrono::time_point<yb::CoarseMonoClock, std::chrono::duration<long long, std::ratio<1l, 1000000000l>>>, yb::ReadHybridTime const&) ${BUILD_ROOT}/../../src/yb/client/transaction_pool.cc:317:24 (libyb_client.so+0x463e84)
    #10 yb::tserver::PgClientSession::GetDdlTransactionMetadata(bool, std::chrono::time_point<yb::CoarseMonoClock, std::chrono::duration<long long, std::ratio<1l, 1000000000l>>>) ${BUILD_ROOT}/../../src/yb/tserver/pg_client_session.cc:945:11 (libtserver.so+0x17bd23)
    #11 yb::tserver::PgClientSession::SetupSession(yb::tserver::PgPerformRequestPB const&, std::chrono::time_point<yb::CoarseMonoClock, std::chrono::duration<long long, std::ratio<1l, 1000000000l>>>) ${BUILD_ROOT}/../../src/yb/tserver/pg_client_session.cc:790:5 (libtserver.so+0x182089)
    #12 yb::tserver::PgClientSession::Perform(yb::tserver::PgPerformRequestPB*, yb::tserver::PgPerformResponsePB*, yb::rpc::RpcContext*) ${BUILD_ROOT}/../../src/yb/tserver/pg_client_session.cc:702:23 (libtserver.so+0x180810)
    #13 yb::tserver::PgClientServiceImpl::Impl::DoPerform(yb::tserver::PgPerformRequestPB*, yb::tserver::PgPerformResponsePB*, yb::rpc::RpcContext*) ${BUILD_ROOT}/../../src/yb/tserver/pg_client_service.cc:475:45 (libtserver.so+0x17955e)
    #14 yb::tserver::PgClientServiceImpl::Impl::Perform(yb::tserver::PgPerformRequestPB*, yb::tserver::PgPerformResponsePB*, yb::rpc::RpcContext*) ${BUILD_ROOT}/../../src/yb/tserver/pg_client_service.cc:396:19 (libtserver.so+0x171d48)
    #15 yb::tserver::PgClientServiceImpl::Perform(yb::tserver::PgPerformRequestPB const*, yb::tserver::PgPerformResponsePB*, yb::rpc::RpcContext) ${BUILD_ROOT}/../../src/yb/tserver/pg_client_service.cc:537:10 (libtserver.so+0x16e6e0)
    #16 yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17::operator()(std::shared_ptr<yb::rpc::InboundCall>) const::'lambda'(yb::tserver::PgPerformRequestPB const*, yb::tserver::PgPerformResponsePB*, yb::rpc::RpcContext)::operator()(yb::tserver::PgPerformRequestPB const*, yb::tserver::PgPerformResponsePB*, yb::rpc::RpcContext) const ${BUILD_ROOT}/src/yb/tserver/pg_client.service.cc:943:9 (libpg_client_proto.so+0x1a51ba)
    #17 auto yb::rpc::HandleCall<yb::rpc::RpcCallPBParamsImpl<yb::tserver::PgPerformRequestPB, yb::tserver::PgPerformResponsePB>, yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17::operator()(std::shared_ptr<yb::rpc::InboundCall>) const::'lambda'(yb::tserver::PgPerformRequestPB const*, yb::tserver::PgPerformResponsePB*, yb::rpc::RpcContext)>(std::shared_ptr<yb::rpc::InboundCall>, yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17::operator()(std::shared_ptr<yb::rpc::InboundCall>) const::'lambda'(yb::tserver::PgPerformRequestPB const*, yb::tserver::PgPerformResponsePB*, yb::rpc::RpcContext)) ${BUILD_ROOT}/../../src/yb/rpc/local_call.h:115:7 (libpg_client_proto.so+0x1a51ba)
    #18 yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17::operator()(std::shared_ptr<yb::rpc::InboundCall>) const ${BUILD_ROOT}/src/yb/tserver/pg_client.service.cc:941:7 (libpg_client_proto.so+0x1a51ba)
    #19 decltype(std::declval<yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17&>()(std::declval<std::shared_ptr<yb::rpc::InboundCall>>())) std::__invoke[abi:v15003]<yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17&, std::shared_ptr<yb::rpc::InboundCall>>(yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17&, std::shared_ptr<yb::rpc::InboundCall>&&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/invoke.h:394:23 (libpg_client_proto.so+0x1a51ba)
    #20 void std::__invoke_void_return_wrapper<void, true>::__call<yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17&, std::shared_ptr<yb::rpc::InboundCall>>(yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17&, std::shared_ptr<yb::rpc::InboundCall>&&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/invoke.h:479:9 (libpg_client_proto.so+0x1a51ba)
    #21 std::__function::__alloc_func<yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17, std::allocator<yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17>, void (std::shared_ptr<yb::rpc::InboundCall>)>::operator()[abi:v15003](std::shared_ptr<yb::rpc::InboundCall>&&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:185:16 (libpg_client_proto.so+0x1a51ba)
    #22 std::__function::__func<yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17, std::allocator<yb::tserver::PgClientServiceIf::InitMethods(scoped_refptr<yb::MetricEntity> const&)::$_17>, void (std::shared_ptr<yb::rpc::InboundCall>)>::operator()(std::shared_ptr<yb::rpc::InboundCall>&&) /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:359:12 (libpg_client_proto.so+0x1a51ba)
    #23 std::__function::__value_func<void (std::shared_ptr<yb::rpc::InboundCall>)>::operator()[abi:v15003](std::shared_ptr<yb::rpc::InboundCall>&&) const /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:512:16 (libpg_client_proto.so+0x198f82)
    #24 std::function<void (std::shared_ptr<yb::rpc::InboundCall>)>::operator()(std::shared_ptr<yb::rpc::InboundCall>) const /opt/yb-build/thirdparty/yugabyte-db-thirdparty-v20221115221900-32d6b89b02-centos7-x86_64-clang15/installed/tsan/libcxx/include/c++/v1/__functional/function.h:1197:12 (libpg_client_proto.so+0x198f82)

PgTableSizeTest_PartitionedTableSize.log

@deeps1991 deeps1991 added area/docdb YugabyteDB core features status/awaiting-triage Issue awaiting triage labels Feb 1, 2023
@yugabyte-ci yugabyte-ci added kind/bug This issue is a bug priority/medium Medium priority issue labels Feb 1, 2023
@yugabyte-ci yugabyte-ci added kind/failing-test Tests and testing infra and removed status/awaiting-triage Issue awaiting triage labels Feb 6, 2023
@yugabyte-ci yugabyte-ci added priority/high High Priority and removed priority/medium Medium priority issue labels Feb 24, 2023
@rthallamko3
Copy link
Contributor

Detective repoort

basavaraj29 added a commit that referenced this issue Apr 7, 2023
…izeTest_PartitionedTableSize

Summary:
As we allow buffering of operations in YSQL, multiple batches are launched in async mode without completion of the previous batch (only when there is no dependency among these operations). There can be only one outstanding batch executing `PgClientSession::SetupSession`, while there can be many outstanding batches executing `YBTransaction::Impl::Prepare` as part of callback from `LookupByKeyRpc`. All these batches belong to the same subtxn id. This can be confirmed as we wait for result of all previously launched in-flight ops in `PgSession::SetActiveSubTransaction`.

In the current implementation, it leads to data race issues with YBSubTransaction. A previously launched batch is trying to access `highest_subtransaction_id_` during the `Prepare` to populate in-flight ops metadata, while a subsequent batch is trying to set the same field `highest_subtransaction_id_`. Though the writer thread tries to overwrite `highest_subtransaction_id_` to the same old value, this leads to a read-write conflict

To address the data race, we now set subtxn metadata for the batch (batch of ops) by setting it during `Batcher::FlushAsync`. Batcher then launches `YBTransaction::Impl::Prepare` for the underlying transaction, which sets only the transaction metadata.

The diff also addresses an anomaly with `active_sub_transaction_id_` passed from `pg_session`. Postgres assigns subtransaction id(s) starting from 1. but in the existing implementation, we see that `active_sub_transaction_id_` starts from 0 and then bumps up to 2 on savepoint creation (value as seen in the requests at `pg_client_session.cc`). In `client/transaction.cc`, we check if savepoint has been created, and if not, leave the subtxn metadata unpopulated. Down the stream, it is assumed that the subtransaction belonged to id 1 since the subtxn metadata was left empty. To avoid this confusion, we change the default value of `active_sub_transaction_id_` and populate the subtxn metadata pb only when subtxn is not in its default state.

Not enabling the test to run in tsan mode for now, as there are a few more race issues that need to be addressed with the pggate code. For instance, the below stack trace points out an issue. (filed github [[ #16390 | issue ]])
```
WARNING: ThreadSanitizer: data race (pid=1415195)
  Read of size 8 at 0x7fb746055e18 by thread T1:
    #0 YBCPgIsYugaByteEnabled /nfusr/dev-server/bkolagani/code/yugabyte-db/build/tsan-clang15-dynamic-ninja/../../src/yb/yql/pggate/ybc_pggate.cc:1368:10 (libyb_pggate.so+0x8f21a)
    #1 IsYugaByteEnabled /nfusr/dev-server/bkolagani/code/yugabyte-db/src/postgres/src/backend/utils/misc/../../../../../../../src/postgres/src/backend/utils/misc/pg_yb_utils.c:177:9 (postgres+0xc77565)
    #2 die /nfusr/dev-server/bkolagani/code/yugabyte-db/src/postgres/src/backend/tcop/../../../../../../src/postgres/src/backend/tcop/postgres.c:2752:6 (postgres+0xa4adc1)
    #3 __tsan::CallUserSignalHandler(__tsan::ThreadState*, bool, bool, int, __sanitizer::__sanitizer_siginfo*, void*) /opt/yb-build/llvm/yb-llvm-v15.0.3-yb-1-1667030060-0b8d1183-almalinux8-x86_64-build/src/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:2025:5 (postgres+0x415a3a)
...
  Previous write of size 8 at 0x7fb746055e18 by main thread:
    #0 YBCDestroyPgGate /nfusr/dev-server/bkolagani/code/yugabyte-db/build/tsan-clang15-dynamic-ninja/../../src/yb/yql/pggate/ybc_pggate.cc:196:11 (libyb_pggate.so+0x866ae)
    #1 YBOnPostgresBackendShutdown /nfusr/dev-server/bkolagani/code/yugabyte-db/src/postgres/src/backend/utils/misc/../../../../../../../src/postgres/src/backend/utils/misc/pg_yb_utils.c:609:2 (postgres+0xc79003)
    #2 proc_exit /nfusr/dev-server/bkolagani/code/yugabyte-db/src/postgres/src/backend/storage/ipc/../../../../../../../src/postgres/src/backend/storage/ipc/ipc.c:153:3 (postgres+0xa080cc)
```

Test Plan:
Jenkins
```
./yb_build.sh --gtest_filter PgTableSizeTest.PartitionedTableSize
```

Reviewers: esheng, rthallam, pjain, rsami

Reviewed By: rthallam, pjain, rsami

Subscribers: bogdan, ybase

Differential Revision: https://phabricator.dev.yugabyte.com/D23412
premkumr pushed a commit to premkumr/yugabyte-db that referenced this issue Apr 10, 2023
…n TableSizeTest_PartitionedTableSize

Summary:
As we allow buffering of operations in YSQL, multiple batches are launched in async mode without completion of the previous batch (only when there is no dependency among these operations). There can be only one outstanding batch executing `PgClientSession::SetupSession`, while there can be many outstanding batches executing `YBTransaction::Impl::Prepare` as part of callback from `LookupByKeyRpc`. All these batches belong to the same subtxn id. This can be confirmed as we wait for result of all previously launched in-flight ops in `PgSession::SetActiveSubTransaction`.

In the current implementation, it leads to data race issues with YBSubTransaction. A previously launched batch is trying to access `highest_subtransaction_id_` during the `Prepare` to populate in-flight ops metadata, while a subsequent batch is trying to set the same field `highest_subtransaction_id_`. Though the writer thread tries to overwrite `highest_subtransaction_id_` to the same old value, this leads to a read-write conflict

To address the data race, we now set subtxn metadata for the batch (batch of ops) by setting it during `Batcher::FlushAsync`. Batcher then launches `YBTransaction::Impl::Prepare` for the underlying transaction, which sets only the transaction metadata.

The diff also addresses an anomaly with `active_sub_transaction_id_` passed from `pg_session`. Postgres assigns subtransaction id(s) starting from 1. but in the existing implementation, we see that `active_sub_transaction_id_` starts from 0 and then bumps up to 2 on savepoint creation (value as seen in the requests at `pg_client_session.cc`). In `client/transaction.cc`, we check if savepoint has been created, and if not, leave the subtxn metadata unpopulated. Down the stream, it is assumed that the subtransaction belonged to id 1 since the subtxn metadata was left empty. To avoid this confusion, we change the default value of `active_sub_transaction_id_` and populate the subtxn metadata pb only when subtxn is not in its default state.

Not enabling the test to run in tsan mode for now, as there are a few more race issues that need to be addressed with the pggate code. For instance, the below stack trace points out an issue. (filed github [[ yugabyte#16390 | issue ]])
```
WARNING: ThreadSanitizer: data race (pid=1415195)
  Read of size 8 at 0x7fb746055e18 by thread T1:
    #0 YBCPgIsYugaByteEnabled /nfusr/dev-server/bkolagani/code/yugabyte-db/build/tsan-clang15-dynamic-ninja/../../src/yb/yql/pggate/ybc_pggate.cc:1368:10 (libyb_pggate.so+0x8f21a)
    #1 IsYugaByteEnabled /nfusr/dev-server/bkolagani/code/yugabyte-db/src/postgres/src/backend/utils/misc/../../../../../../../src/postgres/src/backend/utils/misc/pg_yb_utils.c:177:9 (postgres+0xc77565)
    #2 die /nfusr/dev-server/bkolagani/code/yugabyte-db/src/postgres/src/backend/tcop/../../../../../../src/postgres/src/backend/tcop/postgres.c:2752:6 (postgres+0xa4adc1)
    yugabyte#3 __tsan::CallUserSignalHandler(__tsan::ThreadState*, bool, bool, int, __sanitizer::__sanitizer_siginfo*, void*) /opt/yb-build/llvm/yb-llvm-v15.0.3-yb-1-1667030060-0b8d1183-almalinux8-x86_64-build/src/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:2025:5 (postgres+0x415a3a)
...
  Previous write of size 8 at 0x7fb746055e18 by main thread:
    #0 YBCDestroyPgGate /nfusr/dev-server/bkolagani/code/yugabyte-db/build/tsan-clang15-dynamic-ninja/../../src/yb/yql/pggate/ybc_pggate.cc:196:11 (libyb_pggate.so+0x866ae)
    #1 YBOnPostgresBackendShutdown /nfusr/dev-server/bkolagani/code/yugabyte-db/src/postgres/src/backend/utils/misc/../../../../../../../src/postgres/src/backend/utils/misc/pg_yb_utils.c:609:2 (postgres+0xc79003)
    #2 proc_exit /nfusr/dev-server/bkolagani/code/yugabyte-db/src/postgres/src/backend/storage/ipc/../../../../../../../src/postgres/src/backend/storage/ipc/ipc.c:153:3 (postgres+0xa080cc)
```

Test Plan:
Jenkins
```
./yb_build.sh --gtest_filter PgTableSizeTest.PartitionedTableSize
```

Reviewers: esheng, rthallam, pjain, rsami

Reviewed By: rthallam, pjain, rsami

Subscribers: bogdan, ybase

Differential Revision: https://phabricator.dev.yugabyte.com/D23412
basavaraj29 added a commit that referenced this issue Apr 26, 2023
…ction in TableSizeTest_PartitionedTableSize"

Summary: This reverts commit 8bcb9b4 for master branch.

Test Plan: Jenkins

Reviewers: rsami, rthallam

Reviewed By: rthallam

Subscribers: ybase, bogdan

Differential Revision: https://phabricator.dev.yugabyte.com/D24799
basavaraj29 added a commit that referenced this issue Apr 26, 2023
…ith YBSubTransaction in TableSizeTest_PartitionedTableSize"

Summary:
This reverts commit 8bcb9b4 for 2.18 branch.
Original commit: e5620ba / D24799

Test Plan: Jenkins

Reviewers: rsami, rthallam

Reviewed By: rthallam

Subscribers: bogdan, ybase

Differential Revision: https://phabricator.dev.yugabyte.com/D24837
@basavaraj29
Copy link
Contributor

re-opening this due to #16988

@basavaraj29 basavaraj29 reopened this Apr 26, 2023
@yugabyte-ci yugabyte-ci added priority/medium Medium priority issue and removed priority/high High Priority labels May 31, 2023
basavaraj29 added a commit that referenced this issue May 2, 2024
…es subtxn id semantics at pg/pg_client_service

Summary:
As we allow buffering of operations in YSQL, multiple batches belonging to the same subtxn id are launched in parallel in an async manner. There is only one outstanding batch executing `PgClientSession::SetupSession`, while there can be many outstanding batches executing `YBTransaction::Impl::Prepare` as part of callback from `LookupByKeyRpc`.

In the existing implementation, it leads to data race issues with `YBSubTransaction`. A previously launched batch is trying to access `highest_subtransaction_id_` during `Prepare` to populate in-flight ops metadata, while a subsequent batch is trying to set the same field `highest_subtransaction_id_`. Though the writer thread tries to overwrite `highest_subtransaction_id_` with the same old value, it leads to a data race. Also, for RC transactions, we seem to hit a similar race while executing `RollbackToSubTransaction`. Seems like the pg backend issues a rollback on error before all inflight operations complete.
```
Status PgApiImpl::RollbackToSubTransaction(SubTransactionId id) {
  pg_session_->DropBufferedOperations();
  return pg_session_->RollbackToSubTransaction(id);
}
```

**Change 1**
To address the data race, we now set subtxn metadata for the batch (batch of ops) by setting it during `Batcher::FlushAsync`. Batcher then launches `YBTransaction::Impl::Prepare` for the underlying transaction, which sets only the transaction metadata. If the batch fails, the subtxn metadata is copied to the retry batcher.

**Change 2**
This diff also addresses an anomaly with `active_sub_transaction_id_` passed from `pg_session`. Postgres assigns subtransaction id(s) starting from 1. But in the existing implementation, we see that `active_sub_transaction_id_` starts from 0 and then bumps up to 2 on savepoint creation (value as seen in the requests at `pg_client_session.cc`). In `client/transaction.cc`, we leave the subtxn metadata unpopulated if no savepoint has been created yet. The downstream code assumes that the subtxn belonged to id 1 since the subtxn metadata was unpopulated. To avoid this confusion, we change the default value of `active_sub_transaction_id_` and populate the subtxn metadata pb only when subtxn is not in its default state.

Enabling test `PgTableSizeTest.PartitionedTableSize` to run in tsan mode, as the most of the race issues with pggate are resolved now.

Note: The earlier version of the [[ https://phorge.dev.yugabyte.com/D23412 | fix ]] lead to a data loss [[ #16988 | issue ]] as the subtxn metadata was not being populated for retry batchers (which are quite probable in case of tablet splits). Hence, these ops were wrongly being treated as belonging to `kMinSubtransactionId` by downstream code, which might have lead to the issue. Added a test that validates the reasoning.

**Additional note**
We discussed offline that this change shouldn't have upgrade/downgrade consequences. Since pg process is a child process of the tserver process, changes at pg_client_session/service and pg_txn_manager would have taken effect in combination. So the subtxn metadata in the actual rpc to docdb would remain unchanged.
Jira: DB-5343, DB-10441

Test Plan:
Jenkins
```
./yb_build.sh tsan --gtest_filter PgTableSizeTest.PartitionedTableSize -n 100
./yb_build.sh --gtest_filter PgTabletSplitTest.SplitAmidstRunningTransaction
./yb_builds tsan --cxx-test='TEST_F(GeoPartitionedReadCommiittedTest, TestPromotionAmidstConflicts) {'
```

Reviewers: pjain, esheng, rsami, rthallam

Reviewed By: pjain

Subscribers: yql, ybase, bogdan

Differential Revision: https://phorge.dev.yugabyte.com/D25071
svarnau pushed a commit that referenced this issue May 25, 2024
…es subtxn id semantics at pg/pg_client_service

Summary:
As we allow buffering of operations in YSQL, multiple batches belonging to the same subtxn id are launched in parallel in an async manner. There is only one outstanding batch executing `PgClientSession::SetupSession`, while there can be many outstanding batches executing `YBTransaction::Impl::Prepare` as part of callback from `LookupByKeyRpc`.

In the existing implementation, it leads to data race issues with `YBSubTransaction`. A previously launched batch is trying to access `highest_subtransaction_id_` during `Prepare` to populate in-flight ops metadata, while a subsequent batch is trying to set the same field `highest_subtransaction_id_`. Though the writer thread tries to overwrite `highest_subtransaction_id_` with the same old value, it leads to a data race. Also, for RC transactions, we seem to hit a similar race while executing `RollbackToSubTransaction`. Seems like the pg backend issues a rollback on error before all inflight operations complete.
```
Status PgApiImpl::RollbackToSubTransaction(SubTransactionId id) {
  pg_session_->DropBufferedOperations();
  return pg_session_->RollbackToSubTransaction(id);
}
```

**Change 1**
To address the data race, we now set subtxn metadata for the batch (batch of ops) by setting it during `Batcher::FlushAsync`. Batcher then launches `YBTransaction::Impl::Prepare` for the underlying transaction, which sets only the transaction metadata. If the batch fails, the subtxn metadata is copied to the retry batcher.

**Change 2**
This diff also addresses an anomaly with `active_sub_transaction_id_` passed from `pg_session`. Postgres assigns subtransaction id(s) starting from 1. But in the existing implementation, we see that `active_sub_transaction_id_` starts from 0 and then bumps up to 2 on savepoint creation (value as seen in the requests at `pg_client_session.cc`). In `client/transaction.cc`, we leave the subtxn metadata unpopulated if no savepoint has been created yet. The downstream code assumes that the subtxn belonged to id 1 since the subtxn metadata was unpopulated. To avoid this confusion, we change the default value of `active_sub_transaction_id_` and populate the subtxn metadata pb only when subtxn is not in its default state.

Enabling test `PgTableSizeTest.PartitionedTableSize` to run in tsan mode, as the most of the race issues with pggate are resolved now.

Note: The earlier version of the [[ https://phorge.dev.yugabyte.com/D23412 | fix ]] lead to a data loss [[ #16988 | issue ]] as the subtxn metadata was not being populated for retry batchers (which are quite probable in case of tablet splits). Hence, these ops were wrongly being treated as belonging to `kMinSubtransactionId` by downstream code, which might have lead to the issue. Added a test that validates the reasoning.

**Additional note**
We discussed offline that this change shouldn't have upgrade/downgrade consequences. Since pg process is a child process of the tserver process, changes at pg_client_session/service and pg_txn_manager would have taken effect in combination. So the subtxn metadata in the actual rpc to docdb would remain unchanged.
Jira: DB-5343, DB-10441

Test Plan:
Jenkins
```
./yb_build.sh tsan --gtest_filter PgTableSizeTest.PartitionedTableSize -n 100
./yb_build.sh --gtest_filter PgTabletSplitTest.SplitAmidstRunningTransaction
./yb_builds tsan --cxx-test='TEST_F(GeoPartitionedReadCommiittedTest, TestPromotionAmidstConflicts) {'
```

Reviewers: pjain, esheng, rsami, rthallam

Reviewed By: pjain

Subscribers: yql, ybase, bogdan

Differential Revision: https://phorge.dev.yugabyte.com/D25071
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docdb YugabyteDB core features kind/bug This issue is a bug kind/failing-test Tests and testing infra priority/medium Medium priority issue
Projects
None yet
Development

No branches or pull requests

4 participants