/Users/deen/code/yugabyte-db/src/yb/tserver/service_util.h
Line | Count | Source (jump to first uncovered line) |
1 | | // |
2 | | // Copyright (c) YugaByte, Inc. |
3 | | // |
4 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
5 | | // in compliance with the License. You may obtain a copy of the License at |
6 | | // |
7 | | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
10 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
11 | | // or implied. See the License for the specific language governing permissions and limitations |
12 | | // under the License. |
13 | | // |
14 | | // |
15 | | |
16 | | #ifndef YB_TSERVER_SERVICE_UTIL_H |
17 | | #define YB_TSERVER_SERVICE_UTIL_H |
18 | | |
19 | | #include <boost/optional.hpp> |
20 | | |
21 | | #include "yb/common/wire_protocol.h" |
22 | | #include "yb/consensus/consensus_error.h" |
23 | | |
24 | | #include "yb/rpc/rpc_context.h" |
25 | | #include "yb/server/clock.h" |
26 | | |
27 | | #include "yb/tablet/tablet_fwd.h" |
28 | | #include "yb/tablet/tablet_peer.h" |
29 | | |
30 | | #include "yb/tserver/tablet_peer_lookup.h" |
31 | | #include "yb/tablet/tablet_error.h" |
32 | | #include "yb/tserver/tserver_error.h" |
33 | | |
34 | | #include "yb/util/logging.h" |
35 | | #include "yb/util/result.h" |
36 | | #include "yb/util/status_callback.h" |
37 | | #include "yb/util/status_format.h" |
38 | | |
39 | | namespace yb { |
40 | | namespace tserver { |
41 | | |
42 | | // Non-template helpers. |
43 | | |
44 | | void SetupErrorAndRespond(TabletServerErrorPB* error, |
45 | | const Status& s, |
46 | | TabletServerErrorPB::Code code, |
47 | | rpc::RpcContext* context); |
48 | | |
49 | | void SetupErrorAndRespond(TabletServerErrorPB* error, |
50 | | const Status& s, |
51 | | rpc::RpcContext* context); |
52 | | |
53 | | void SetupError(TabletServerErrorPB* error, const Status& s); |
54 | | |
55 | | Result<int64_t> LeaderTerm(const tablet::TabletPeer& tablet_peer); |
56 | | |
57 | | // Template helpers. |
58 | | |
59 | | template<class ReqClass> |
60 | | Result<bool> CheckUuidMatch(TabletPeerLookupIf* tablet_manager, |
61 | | const char* method_name, |
62 | | const ReqClass* req, |
63 | 27.3M | const std::string& requestor_string) { |
64 | 27.3M | const string& local_uuid = tablet_manager->NodeInstance().permanent_uuid(); |
65 | 27.3M | if (req->dest_uuid().empty()) { |
66 | | // Maintain compat in release mode, but complain. |
67 | 0 | string msg = strings::Substitute("$0: Missing destination UUID in request from $1: $2", |
68 | 0 | method_name, requestor_string, req->ShortDebugString()); |
69 | | #ifdef NDEBUG |
70 | | YB_LOG_EVERY_N(ERROR, 100) << msg; |
71 | | #else |
72 | 0 | LOG(FATAL) << msg; |
73 | 0 | #endif |
74 | 0 | return true; |
75 | 0 | } |
76 | 27.3M | if (PREDICT_FALSE(req->dest_uuid() != local_uuid)) { |
77 | 2.35k | const Status s = STATUS_SUBSTITUTE(InvalidArgument, |
78 | 2.35k | "$0: Wrong destination UUID requested. Local UUID: $1. Requested UUID: $2", |
79 | 2.35k | method_name, local_uuid, req->dest_uuid()); |
80 | 2.35k | LOG(WARNING) << s.ToString() << ": from " << requestor_string |
81 | 2.35k | << ": " << req->ShortDebugString(); |
82 | 2.35k | return s.CloneAndAddErrorCode(TabletServerError(TabletServerErrorPB::WRONG_SERVER_UUID)); |
83 | 2.35k | } |
84 | 27.3M | return true; |
85 | 27.3M | } yb::Result<bool> yb::tserver::CheckUuidMatch<yb::tablet::ChangeMetadataRequestPB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::tablet::ChangeMetadataRequestPB const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 63 | 32.3k | const std::string& requestor_string) { | 64 | 32.3k | const string& local_uuid = tablet_manager->NodeInstance().permanent_uuid(); | 65 | 32.3k | if (req->dest_uuid().empty()) { | 66 | | // Maintain compat in release mode, but complain. | 67 | 0 | string msg = strings::Substitute("$0: Missing destination UUID in request from $1: $2", | 68 | 0 | method_name, requestor_string, req->ShortDebugString()); | 69 | | #ifdef NDEBUG | 70 | | YB_LOG_EVERY_N(ERROR, 100) << msg; | 71 | | #else | 72 | 0 | LOG(FATAL) << msg; | 73 | 0 | #endif | 74 | 0 | return true; | 75 | 0 | } | 76 | 32.3k | if (PREDICT_FALSE(req->dest_uuid() != local_uuid)) { | 77 | 0 | const Status s = STATUS_SUBSTITUTE(InvalidArgument, | 78 | 0 | "$0: Wrong destination UUID requested. Local UUID: $1. Requested UUID: $2", | 79 | 0 | method_name, local_uuid, req->dest_uuid()); | 80 | 0 | LOG(WARNING) << s.ToString() << ": from " << requestor_string | 81 | 0 | << ": " << req->ShortDebugString(); | 82 | 0 | return s.CloneAndAddErrorCode(TabletServerError(TabletServerErrorPB::WRONG_SERVER_UUID)); | 83 | 0 | } | 84 | 32.3k | return true; | 85 | 32.3k | } |
yb::Result<bool> yb::tserver::CheckUuidMatch<yb::tserver::GetSafeTimeRequestPB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::tserver::GetSafeTimeRequestPB const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 63 | 4.39k | const std::string& requestor_string) { | 64 | 4.39k | const string& local_uuid = tablet_manager->NodeInstance().permanent_uuid(); | 65 | 4.39k | if (req->dest_uuid().empty()) { | 66 | | // Maintain compat in release mode, but complain. | 67 | 0 | string msg = strings::Substitute("$0: Missing destination UUID in request from $1: $2", | 68 | 0 | method_name, requestor_string, req->ShortDebugString()); | 69 | | #ifdef NDEBUG | 70 | | YB_LOG_EVERY_N(ERROR, 100) << msg; | 71 | | #else | 72 | 0 | LOG(FATAL) << msg; | 73 | 0 | #endif | 74 | 0 | return true; | 75 | 0 | } | 76 | 4.39k | if (PREDICT_FALSE(req->dest_uuid() != local_uuid)) { | 77 | 0 | const Status s = STATUS_SUBSTITUTE(InvalidArgument, | 78 | 0 | "$0: Wrong destination UUID requested. Local UUID: $1. Requested UUID: $2", | 79 | 0 | method_name, local_uuid, req->dest_uuid()); | 80 | 0 | LOG(WARNING) << s.ToString() << ": from " << requestor_string | 81 | 0 | << ": " << req->ShortDebugString(); | 82 | 0 | return s.CloneAndAddErrorCode(TabletServerError(TabletServerErrorPB::WRONG_SERVER_UUID)); | 83 | 0 | } | 84 | 4.39k | return true; | 85 | 4.39k | } |
yb::Result<bool> yb::tserver::CheckUuidMatch<yb::tserver::BackfillIndexRequestPB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::tserver::BackfillIndexRequestPB const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 63 | 4.51k | const std::string& requestor_string) { | 64 | 4.51k | const string& local_uuid = tablet_manager->NodeInstance().permanent_uuid(); | 65 | 4.51k | if (req->dest_uuid().empty()) { | 66 | | // Maintain compat in release mode, but complain. | 67 | 0 | string msg = strings::Substitute("$0: Missing destination UUID in request from $1: $2", | 68 | 0 | method_name, requestor_string, req->ShortDebugString()); | 69 | | #ifdef NDEBUG | 70 | | YB_LOG_EVERY_N(ERROR, 100) << msg; | 71 | | #else | 72 | 0 | LOG(FATAL) << msg; | 73 | 0 | #endif | 74 | 0 | return true; | 75 | 0 | } | 76 | 4.51k | if (PREDICT_FALSE(req->dest_uuid() != local_uuid)) { | 77 | 0 | const Status s = STATUS_SUBSTITUTE(InvalidArgument, | 78 | 0 | "$0: Wrong destination UUID requested. Local UUID: $1. Requested UUID: $2", | 79 | 0 | method_name, local_uuid, req->dest_uuid()); | 80 | 0 | LOG(WARNING) << s.ToString() << ": from " << requestor_string | 81 | 0 | << ": " << req->ShortDebugString(); | 82 | 0 | return s.CloneAndAddErrorCode(TabletServerError(TabletServerErrorPB::WRONG_SERVER_UUID)); | 83 | 0 | } | 84 | 4.51k | return true; | 85 | 4.51k | } |
yb::Result<bool> yb::tserver::CheckUuidMatch<yb::tserver::CreateTabletRequestPB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::tserver::CreateTabletRequestPB const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 63 | 139k | const std::string& requestor_string) { | 64 | 139k | const string& local_uuid = tablet_manager->NodeInstance().permanent_uuid(); | 65 | 139k | if (req->dest_uuid().empty()) { | 66 | | // Maintain compat in release mode, but complain. | 67 | 0 | string msg = strings::Substitute("$0: Missing destination UUID in request from $1: $2", | 68 | 0 | method_name, requestor_string, req->ShortDebugString()); | 69 | | #ifdef NDEBUG | 70 | | YB_LOG_EVERY_N(ERROR, 100) << msg; | 71 | | #else | 72 | 0 | LOG(FATAL) << msg; | 73 | 0 | #endif | 74 | 0 | return true; | 75 | 0 | } | 76 | 139k | if (PREDICT_FALSE(req->dest_uuid() != local_uuid)) { | 77 | 0 | const Status s = STATUS_SUBSTITUTE(InvalidArgument, | 78 | 0 | "$0: Wrong destination UUID requested. Local UUID: $1. Requested UUID: $2", | 79 | 0 | method_name, local_uuid, req->dest_uuid()); | 80 | 0 | LOG(WARNING) << s.ToString() << ": from " << requestor_string | 81 | 0 | << ": " << req->ShortDebugString(); | 82 | 0 | return s.CloneAndAddErrorCode(TabletServerError(TabletServerErrorPB::WRONG_SERVER_UUID)); | 83 | 0 | } | 84 | 139k | return true; | 85 | 139k | } |
yb::Result<bool> yb::tserver::CheckUuidMatch<yb::tserver::DeleteTabletRequestPB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::tserver::DeleteTabletRequestPB const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 63 | 77.3k | const std::string& requestor_string) { | 64 | 77.3k | const string& local_uuid = tablet_manager->NodeInstance().permanent_uuid(); | 65 | 77.3k | if (req->dest_uuid().empty()) { | 66 | | // Maintain compat in release mode, but complain. | 67 | 0 | string msg = strings::Substitute("$0: Missing destination UUID in request from $1: $2", | 68 | 0 | method_name, requestor_string, req->ShortDebugString()); | 69 | | #ifdef NDEBUG | 70 | | YB_LOG_EVERY_N(ERROR, 100) << msg; | 71 | | #else | 72 | 0 | LOG(FATAL) << msg; | 73 | 0 | #endif | 74 | 0 | return true; | 75 | 0 | } | 76 | 77.3k | if (PREDICT_FALSE(req->dest_uuid() != local_uuid)) { | 77 | 1 | const Status s = STATUS_SUBSTITUTE(InvalidArgument, | 78 | 1 | "$0: Wrong destination UUID requested. Local UUID: $1. Requested UUID: $2", | 79 | 1 | method_name, local_uuid, req->dest_uuid()); | 80 | 1 | LOG(WARNING) << s.ToString() << ": from " << requestor_string | 81 | 1 | << ": " << req->ShortDebugString(); | 82 | 1 | return s.CloneAndAddErrorCode(TabletServerError(TabletServerErrorPB::WRONG_SERVER_UUID)); | 83 | 1 | } | 84 | 77.3k | return true; | 85 | 77.3k | } |
yb::Result<bool> yb::tserver::CheckUuidMatch<yb::tserver::FlushTabletsRequestPB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::tserver::FlushTabletsRequestPB const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 63 | 43 | const std::string& requestor_string) { | 64 | 43 | const string& local_uuid = tablet_manager->NodeInstance().permanent_uuid(); | 65 | 43 | if (req->dest_uuid().empty()) { | 66 | | // Maintain compat in release mode, but complain. | 67 | 0 | string msg = strings::Substitute("$0: Missing destination UUID in request from $1: $2", | 68 | 0 | method_name, requestor_string, req->ShortDebugString()); | 69 | | #ifdef NDEBUG | 70 | | YB_LOG_EVERY_N(ERROR, 100) << msg; | 71 | | #else | 72 | 0 | LOG(FATAL) << msg; | 73 | 0 | #endif | 74 | 0 | return true; | 75 | 0 | } | 76 | 43 | if (PREDICT_FALSE(req->dest_uuid() != local_uuid)) { | 77 | 0 | const Status s = STATUS_SUBSTITUTE(InvalidArgument, | 78 | 0 | "$0: Wrong destination UUID requested. Local UUID: $1. Requested UUID: $2", | 79 | 0 | method_name, local_uuid, req->dest_uuid()); | 80 | 0 | LOG(WARNING) << s.ToString() << ": from " << requestor_string | 81 | 0 | << ": " << req->ShortDebugString(); | 82 | 0 | return s.CloneAndAddErrorCode(TabletServerError(TabletServerErrorPB::WRONG_SERVER_UUID)); | 83 | 0 | } | 84 | 43 | return true; | 85 | 43 | } |
yb::Result<bool> yb::tserver::CheckUuidMatch<yb::tablet::SplitTabletRequestPB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::tablet::SplitTabletRequestPB const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 63 | 141 | const std::string& requestor_string) { | 64 | 141 | const string& local_uuid = tablet_manager->NodeInstance().permanent_uuid(); | 65 | 141 | if (req->dest_uuid().empty()) { | 66 | | // Maintain compat in release mode, but complain. | 67 | 0 | string msg = strings::Substitute("$0: Missing destination UUID in request from $1: $2", | 68 | 0 | method_name, requestor_string, req->ShortDebugString()); | 69 | | #ifdef NDEBUG | 70 | | YB_LOG_EVERY_N(ERROR, 100) << msg; | 71 | | #else | 72 | 0 | LOG(FATAL) << msg; | 73 | 0 | #endif | 74 | 0 | return true; | 75 | 0 | } | 76 | 141 | if (PREDICT_FALSE(req->dest_uuid() != local_uuid)) { | 77 | 0 | const Status s = STATUS_SUBSTITUTE(InvalidArgument, | 78 | 0 | "$0: Wrong destination UUID requested. Local UUID: $1. Requested UUID: $2", | 79 | 0 | method_name, local_uuid, req->dest_uuid()); | 80 | 0 | LOG(WARNING) << s.ToString() << ": from " << requestor_string | 81 | 0 | << ": " << req->ShortDebugString(); | 82 | 0 | return s.CloneAndAddErrorCode(TabletServerError(TabletServerErrorPB::WRONG_SERVER_UUID)); | 83 | 0 | } | 84 | 141 | return true; | 85 | 141 | } |
yb::Result<bool> yb::tserver::CheckUuidMatch<yb::consensus::ConsensusRequestPB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::consensus::ConsensusRequestPB const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 63 | 25.5M | const std::string& requestor_string) { | 64 | 25.5M | const string& local_uuid = tablet_manager->NodeInstance().permanent_uuid(); | 65 | 25.5M | if (req->dest_uuid().empty()) { | 66 | | // Maintain compat in release mode, but complain. | 67 | 0 | string msg = strings::Substitute("$0: Missing destination UUID in request from $1: $2", | 68 | 0 | method_name, requestor_string, req->ShortDebugString()); | 69 | | #ifdef NDEBUG | 70 | | YB_LOG_EVERY_N(ERROR, 100) << msg; | 71 | | #else | 72 | 0 | LOG(FATAL) << msg; | 73 | 0 | #endif | 74 | 0 | return true; | 75 | 0 | } | 76 | 25.5M | if (PREDICT_FALSE(req->dest_uuid() != local_uuid)) { | 77 | 95 | const Status s = STATUS_SUBSTITUTE(InvalidArgument, | 78 | 95 | "$0: Wrong destination UUID requested. Local UUID: $1. Requested UUID: $2", | 79 | 95 | method_name, local_uuid, req->dest_uuid()); | 80 | 95 | LOG(WARNING) << s.ToString() << ": from " << requestor_string | 81 | 95 | << ": " << req->ShortDebugString(); | 82 | 95 | return s.CloneAndAddErrorCode(TabletServerError(TabletServerErrorPB::WRONG_SERVER_UUID)); | 83 | 95 | } | 84 | 25.5M | return true; | 85 | 25.5M | } |
yb::Result<bool> yb::tserver::CheckUuidMatch<yb::consensus::VoteRequestPB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::consensus::VoteRequestPB const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 63 | 1.39M | const std::string& requestor_string) { | 64 | 1.39M | const string& local_uuid = tablet_manager->NodeInstance().permanent_uuid(); | 65 | 1.39M | if (req->dest_uuid().empty()) { | 66 | | // Maintain compat in release mode, but complain. | 67 | 0 | string msg = strings::Substitute("$0: Missing destination UUID in request from $1: $2", | 68 | 0 | method_name, requestor_string, req->ShortDebugString()); | 69 | | #ifdef NDEBUG | 70 | | YB_LOG_EVERY_N(ERROR, 100) << msg; | 71 | | #else | 72 | 0 | LOG(FATAL) << msg; | 73 | 0 | #endif | 74 | 0 | return true; | 75 | 0 | } | 76 | 1.39M | if (PREDICT_FALSE(req->dest_uuid() != local_uuid)) { | 77 | 2.26k | const Status s = STATUS_SUBSTITUTE(InvalidArgument, | 78 | 2.26k | "$0: Wrong destination UUID requested. Local UUID: $1. Requested UUID: $2", | 79 | 2.26k | method_name, local_uuid, req->dest_uuid()); | 80 | 2.26k | LOG(WARNING) << s.ToString() << ": from " << requestor_string | 81 | 2.26k | << ": " << req->ShortDebugString(); | 82 | 2.26k | return s.CloneAndAddErrorCode(TabletServerError(TabletServerErrorPB::WRONG_SERVER_UUID)); | 83 | 2.26k | } | 84 | 1.39M | return true; | 85 | 1.39M | } |
yb::Result<bool> yb::tserver::CheckUuidMatch<yb::consensus::ChangeConfigRequestPB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::consensus::ChangeConfigRequestPB const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 63 | 5.14k | const std::string& requestor_string) { | 64 | 5.14k | const string& local_uuid = tablet_manager->NodeInstance().permanent_uuid(); | 65 | 5.14k | if (req->dest_uuid().empty()) { | 66 | | // Maintain compat in release mode, but complain. | 67 | 0 | string msg = strings::Substitute("$0: Missing destination UUID in request from $1: $2", | 68 | 0 | method_name, requestor_string, req->ShortDebugString()); | 69 | | #ifdef NDEBUG | 70 | | YB_LOG_EVERY_N(ERROR, 100) << msg; | 71 | | #else | 72 | 0 | LOG(FATAL) << msg; | 73 | 0 | #endif | 74 | 0 | return true; | 75 | 0 | } | 76 | 5.14k | if (PREDICT_FALSE(req->dest_uuid() != local_uuid)) { | 77 | 0 | const Status s = STATUS_SUBSTITUTE(InvalidArgument, | 78 | 0 | "$0: Wrong destination UUID requested. Local UUID: $1. Requested UUID: $2", | 79 | 0 | method_name, local_uuid, req->dest_uuid()); | 80 | 0 | LOG(WARNING) << s.ToString() << ": from " << requestor_string | 81 | 0 | << ": " << req->ShortDebugString(); | 82 | 0 | return s.CloneAndAddErrorCode(TabletServerError(TabletServerErrorPB::WRONG_SERVER_UUID)); | 83 | 0 | } | 84 | 5.14k | return true; | 85 | 5.14k | } |
yb::Result<bool> yb::tserver::CheckUuidMatch<yb::consensus::UnsafeChangeConfigRequestPB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::consensus::UnsafeChangeConfigRequestPB const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 63 | 6 | const std::string& requestor_string) { | 64 | 6 | const string& local_uuid = tablet_manager->NodeInstance().permanent_uuid(); | 65 | 6 | if (req->dest_uuid().empty()) { | 66 | | // Maintain compat in release mode, but complain. | 67 | 0 | string msg = strings::Substitute("$0: Missing destination UUID in request from $1: $2", | 68 | 0 | method_name, requestor_string, req->ShortDebugString()); | 69 | | #ifdef NDEBUG | 70 | | YB_LOG_EVERY_N(ERROR, 100) << msg; | 71 | | #else | 72 | 0 | LOG(FATAL) << msg; | 73 | 0 | #endif | 74 | 0 | return true; | 75 | 0 | } | 76 | 6 | if (PREDICT_FALSE(req->dest_uuid() != local_uuid)) { | 77 | 0 | const Status s = STATUS_SUBSTITUTE(InvalidArgument, | 78 | 0 | "$0: Wrong destination UUID requested. Local UUID: $1. Requested UUID: $2", | 79 | 0 | method_name, local_uuid, req->dest_uuid()); | 80 | 0 | LOG(WARNING) << s.ToString() << ": from " << requestor_string | 81 | 0 | << ": " << req->ShortDebugString(); | 82 | 0 | return s.CloneAndAddErrorCode(TabletServerError(TabletServerErrorPB::WRONG_SERVER_UUID)); | 83 | 0 | } | 84 | 6 | return true; | 85 | 6 | } |
yb::Result<bool> yb::tserver::CheckUuidMatch<yb::consensus::RunLeaderElectionRequestPB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::consensus::RunLeaderElectionRequestPB const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 63 | 96.0k | const std::string& requestor_string) { | 64 | 96.0k | const string& local_uuid = tablet_manager->NodeInstance().permanent_uuid(); | 65 | 96.0k | if (req->dest_uuid().empty()) { | 66 | | // Maintain compat in release mode, but complain. | 67 | 0 | string msg = strings::Substitute("$0: Missing destination UUID in request from $1: $2", | 68 | 0 | method_name, requestor_string, req->ShortDebugString()); | 69 | | #ifdef NDEBUG | 70 | | YB_LOG_EVERY_N(ERROR, 100) << msg; | 71 | | #else | 72 | 0 | LOG(FATAL) << msg; | 73 | 0 | #endif | 74 | 0 | return true; | 75 | 0 | } | 76 | 96.0k | if (PREDICT_FALSE(req->dest_uuid() != local_uuid)) { | 77 | 0 | const Status s = STATUS_SUBSTITUTE(InvalidArgument, | 78 | 0 | "$0: Wrong destination UUID requested. Local UUID: $1. Requested UUID: $2", | 79 | 0 | method_name, local_uuid, req->dest_uuid()); | 80 | 0 | LOG(WARNING) << s.ToString() << ": from " << requestor_string | 81 | 0 | << ": " << req->ShortDebugString(); | 82 | 0 | return s.CloneAndAddErrorCode(TabletServerError(TabletServerErrorPB::WRONG_SERVER_UUID)); | 83 | 0 | } | 84 | 96.0k | return true; | 85 | 96.0k | } |
yb::Result<bool> yb::tserver::CheckUuidMatch<yb::consensus::LeaderElectionLostRequestPB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::consensus::LeaderElectionLostRequestPB const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 63 | 77 | const std::string& requestor_string) { | 64 | 77 | const string& local_uuid = tablet_manager->NodeInstance().permanent_uuid(); | 65 | 77 | if (req->dest_uuid().empty()) { | 66 | | // Maintain compat in release mode, but complain. | 67 | 0 | string msg = strings::Substitute("$0: Missing destination UUID in request from $1: $2", | 68 | 0 | method_name, requestor_string, req->ShortDebugString()); | 69 | | #ifdef NDEBUG | 70 | | YB_LOG_EVERY_N(ERROR, 100) << msg; | 71 | | #else | 72 | 0 | LOG(FATAL) << msg; | 73 | 0 | #endif | 74 | 0 | return true; | 75 | 0 | } | 76 | 77 | if (PREDICT_FALSE(req->dest_uuid() != local_uuid)) { | 77 | 0 | const Status s = STATUS_SUBSTITUTE(InvalidArgument, | 78 | 0 | "$0: Wrong destination UUID requested. Local UUID: $1. Requested UUID: $2", | 79 | 0 | method_name, local_uuid, req->dest_uuid()); | 80 | 0 | LOG(WARNING) << s.ToString() << ": from " << requestor_string | 81 | 0 | << ": " << req->ShortDebugString(); | 82 | 0 | return s.CloneAndAddErrorCode(TabletServerError(TabletServerErrorPB::WRONG_SERVER_UUID)); | 83 | 0 | } | 84 | 77 | return true; | 85 | 77 | } |
yb::Result<bool> yb::tserver::CheckUuidMatch<yb::consensus::LeaderStepDownRequestPB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::consensus::LeaderStepDownRequestPB const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 63 | 54.1k | const std::string& requestor_string) { | 64 | 54.1k | const string& local_uuid = tablet_manager->NodeInstance().permanent_uuid(); | 65 | 54.1k | if (req->dest_uuid().empty()) { | 66 | | // Maintain compat in release mode, but complain. | 67 | 0 | string msg = strings::Substitute("$0: Missing destination UUID in request from $1: $2", | 68 | 0 | method_name, requestor_string, req->ShortDebugString()); | 69 | | #ifdef NDEBUG | 70 | | YB_LOG_EVERY_N(ERROR, 100) << msg; | 71 | | #else | 72 | 0 | LOG(FATAL) << msg; | 73 | 0 | #endif | 74 | 0 | return true; | 75 | 0 | } | 76 | 54.1k | if (PREDICT_FALSE(req->dest_uuid() != local_uuid)) { | 77 | 0 | const Status s = STATUS_SUBSTITUTE(InvalidArgument, | 78 | 0 | "$0: Wrong destination UUID requested. Local UUID: $1. Requested UUID: $2", | 79 | 0 | method_name, local_uuid, req->dest_uuid()); | 80 | 0 | LOG(WARNING) << s.ToString() << ": from " << requestor_string | 81 | 0 | << ": " << req->ShortDebugString(); | 82 | 0 | return s.CloneAndAddErrorCode(TabletServerError(TabletServerErrorPB::WRONG_SERVER_UUID)); | 83 | 0 | } | 84 | 54.1k | return true; | 85 | 54.1k | } |
yb::Result<bool> yb::tserver::CheckUuidMatch<yb::consensus::GetLastOpIdRequestPB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::consensus::GetLastOpIdRequestPB const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 63 | 575 | const std::string& requestor_string) { | 64 | 575 | const string& local_uuid = tablet_manager->NodeInstance().permanent_uuid(); | 65 | 575 | if (req->dest_uuid().empty()) { | 66 | | // Maintain compat in release mode, but complain. | 67 | 0 | string msg = strings::Substitute("$0: Missing destination UUID in request from $1: $2", | 68 | 0 | method_name, requestor_string, req->ShortDebugString()); | 69 | | #ifdef NDEBUG | 70 | | YB_LOG_EVERY_N(ERROR, 100) << msg; | 71 | | #else | 72 | 0 | LOG(FATAL) << msg; | 73 | 0 | #endif | 74 | 0 | return true; | 75 | 0 | } | 76 | 575 | if (PREDICT_FALSE(req->dest_uuid() != local_uuid)) { | 77 | 0 | const Status s = STATUS_SUBSTITUTE(InvalidArgument, | 78 | 0 | "$0: Wrong destination UUID requested. Local UUID: $1. Requested UUID: $2", | 79 | 0 | method_name, local_uuid, req->dest_uuid()); | 80 | 0 | LOG(WARNING) << s.ToString() << ": from " << requestor_string | 81 | 0 | << ": " << req->ShortDebugString(); | 82 | 0 | return s.CloneAndAddErrorCode(TabletServerError(TabletServerErrorPB::WRONG_SERVER_UUID)); | 83 | 0 | } | 84 | 575 | return true; | 85 | 575 | } |
yb::Result<bool> yb::tserver::CheckUuidMatch<yb::consensus::GetConsensusStateRequestPB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::consensus::GetConsensusStateRequestPB const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 63 | 4.06k | const std::string& requestor_string) { | 64 | 4.06k | const string& local_uuid = tablet_manager->NodeInstance().permanent_uuid(); | 65 | 4.06k | if (req->dest_uuid().empty()) { | 66 | | // Maintain compat in release mode, but complain. | 67 | 0 | string msg = strings::Substitute("$0: Missing destination UUID in request from $1: $2", | 68 | 0 | method_name, requestor_string, req->ShortDebugString()); | 69 | | #ifdef NDEBUG | 70 | | YB_LOG_EVERY_N(ERROR, 100) << msg; | 71 | | #else | 72 | 0 | LOG(FATAL) << msg; | 73 | 0 | #endif | 74 | 0 | return true; | 75 | 0 | } | 76 | 4.06k | if (PREDICT_FALSE(req->dest_uuid() != local_uuid)) { | 77 | 0 | const Status s = STATUS_SUBSTITUTE(InvalidArgument, | 78 | 0 | "$0: Wrong destination UUID requested. Local UUID: $1. Requested UUID: $2", | 79 | 0 | method_name, local_uuid, req->dest_uuid()); | 80 | 0 | LOG(WARNING) << s.ToString() << ": from " << requestor_string | 81 | 0 | << ": " << req->ShortDebugString(); | 82 | 0 | return s.CloneAndAddErrorCode(TabletServerError(TabletServerErrorPB::WRONG_SERVER_UUID)); | 83 | 0 | } | 84 | 4.06k | return true; | 85 | 4.06k | } |
yb::Result<bool> yb::tserver::CheckUuidMatch<yb::consensus::StartRemoteBootstrapRequestPB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::consensus::StartRemoteBootstrapRequestPB const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 63 | 10.6k | const std::string& requestor_string) { | 64 | 10.6k | const string& local_uuid = tablet_manager->NodeInstance().permanent_uuid(); | 65 | 10.6k | if (req->dest_uuid().empty()) { | 66 | | // Maintain compat in release mode, but complain. | 67 | 0 | string msg = strings::Substitute("$0: Missing destination UUID in request from $1: $2", | 68 | 0 | method_name, requestor_string, req->ShortDebugString()); | 69 | | #ifdef NDEBUG | 70 | | YB_LOG_EVERY_N(ERROR, 100) << msg; | 71 | | #else | 72 | 0 | LOG(FATAL) << msg; | 73 | 0 | #endif | 74 | 0 | return true; | 75 | 0 | } | 76 | 10.6k | if (PREDICT_FALSE(req->dest_uuid() != local_uuid)) { | 77 | 0 | const Status s = STATUS_SUBSTITUTE(InvalidArgument, | 78 | 0 | "$0: Wrong destination UUID requested. Local UUID: $1. Requested UUID: $2", | 79 | 0 | method_name, local_uuid, req->dest_uuid()); | 80 | 0 | LOG(WARNING) << s.ToString() << ": from " << requestor_string | 81 | 0 | << ": " << req->ShortDebugString(); | 82 | 0 | return s.CloneAndAddErrorCode(TabletServerError(TabletServerErrorPB::WRONG_SERVER_UUID)); | 83 | 0 | } | 84 | 10.6k | return true; | 85 | 10.6k | } |
yb::Result<bool> yb::tserver::CheckUuidMatch<yb::tserver::TabletSnapshotOpRequestPB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::tserver::TabletSnapshotOpRequestPB const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Line | Count | Source | 63 | 54 | const std::string& requestor_string) { | 64 | 54 | const string& local_uuid = tablet_manager->NodeInstance().permanent_uuid(); | 65 | 54 | if (req->dest_uuid().empty()) { | 66 | | // Maintain compat in release mode, but complain. | 67 | 0 | string msg = strings::Substitute("$0: Missing destination UUID in request from $1: $2", | 68 | 0 | method_name, requestor_string, req->ShortDebugString()); | 69 | | #ifdef NDEBUG | 70 | | YB_LOG_EVERY_N(ERROR, 100) << msg; | 71 | | #else | 72 | 0 | LOG(FATAL) << msg; | 73 | 0 | #endif | 74 | 0 | return true; | 75 | 0 | } | 76 | 54 | if (PREDICT_FALSE(req->dest_uuid() != local_uuid)) { | 77 | 0 | const Status s = STATUS_SUBSTITUTE(InvalidArgument, | 78 | 0 | "$0: Wrong destination UUID requested. Local UUID: $1. Requested UUID: $2", | 79 | 0 | method_name, local_uuid, req->dest_uuid()); | 80 | 0 | LOG(WARNING) << s.ToString() << ": from " << requestor_string | 81 | 0 | << ": " << req->ShortDebugString(); | 82 | 0 | return s.CloneAndAddErrorCode(TabletServerError(TabletServerErrorPB::WRONG_SERVER_UUID)); | 83 | 0 | } | 84 | 54 | return true; | 85 | 54 | } |
|
86 | | |
87 | | template<class ReqClass, class RespClass> |
88 | | bool CheckUuidMatchOrRespond(TabletPeerLookupIf* tablet_manager, |
89 | | const char* method_name, |
90 | | const ReqClass* req, |
91 | | RespClass* resp, |
92 | 27.3M | rpc::RpcContext* context) { |
93 | 27.3M | Result<bool> result = CheckUuidMatch(tablet_manager, method_name, |
94 | 27.3M | req, context->requestor_string()); |
95 | 27.3M | if (!result.ok()) { |
96 | 2.35k | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); |
97 | 2.35k | return false; |
98 | 2.35k | } |
99 | 27.3M | return result.get(); |
100 | 27.3M | } bool yb::tserver::CheckUuidMatchOrRespond<yb::tablet::ChangeMetadataRequestPB, yb::tserver::ChangeMetadataResponsePB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::tablet::ChangeMetadataRequestPB const*, yb::tserver::ChangeMetadataResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 92 | 32.2k | rpc::RpcContext* context) { | 93 | 32.2k | Result<bool> result = CheckUuidMatch(tablet_manager, method_name, | 94 | 32.2k | req, context->requestor_string()); | 95 | 32.2k | if (!result.ok()) { | 96 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 97 | 0 | return false; | 98 | 0 | } | 99 | 32.2k | return result.get(); | 100 | 32.2k | } |
bool yb::tserver::CheckUuidMatchOrRespond<yb::tserver::GetSafeTimeRequestPB, yb::tserver::GetSafeTimeResponsePB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::tserver::GetSafeTimeRequestPB const*, yb::tserver::GetSafeTimeResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 92 | 4.39k | rpc::RpcContext* context) { | 93 | 4.39k | Result<bool> result = CheckUuidMatch(tablet_manager, method_name, | 94 | 4.39k | req, context->requestor_string()); | 95 | 4.39k | if (!result.ok()) { | 96 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 97 | 0 | return false; | 98 | 0 | } | 99 | 4.39k | return result.get(); | 100 | 4.39k | } |
bool yb::tserver::CheckUuidMatchOrRespond<yb::tserver::BackfillIndexRequestPB, yb::tserver::BackfillIndexResponsePB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::tserver::BackfillIndexRequestPB const*, yb::tserver::BackfillIndexResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 92 | 4.51k | rpc::RpcContext* context) { | 93 | 4.51k | Result<bool> result = CheckUuidMatch(tablet_manager, method_name, | 94 | 4.51k | req, context->requestor_string()); | 95 | 4.51k | if (!result.ok()) { | 96 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 97 | 0 | return false; | 98 | 0 | } | 99 | 4.51k | return result.get(); | 100 | 4.51k | } |
bool yb::tserver::CheckUuidMatchOrRespond<yb::tserver::CreateTabletRequestPB, yb::tserver::CreateTabletResponsePB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::tserver::CreateTabletRequestPB const*, yb::tserver::CreateTabletResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 92 | 139k | rpc::RpcContext* context) { | 93 | 139k | Result<bool> result = CheckUuidMatch(tablet_manager, method_name, | 94 | 139k | req, context->requestor_string()); | 95 | 139k | if (!result.ok()) { | 96 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 97 | 0 | return false; | 98 | 0 | } | 99 | 139k | return result.get(); | 100 | 139k | } |
bool yb::tserver::CheckUuidMatchOrRespond<yb::tserver::DeleteTabletRequestPB, yb::tserver::DeleteTabletResponsePB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::tserver::DeleteTabletRequestPB const*, yb::tserver::DeleteTabletResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 92 | 77.3k | rpc::RpcContext* context) { | 93 | 77.3k | Result<bool> result = CheckUuidMatch(tablet_manager, method_name, | 94 | 77.3k | req, context->requestor_string()); | 95 | 77.3k | if (!result.ok()) { | 96 | 1 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 97 | 1 | return false; | 98 | 1 | } | 99 | 77.3k | return result.get(); | 100 | 77.3k | } |
bool yb::tserver::CheckUuidMatchOrRespond<yb::tserver::FlushTabletsRequestPB, yb::tserver::FlushTabletsResponsePB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::tserver::FlushTabletsRequestPB const*, yb::tserver::FlushTabletsResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 92 | 43 | rpc::RpcContext* context) { | 93 | 43 | Result<bool> result = CheckUuidMatch(tablet_manager, method_name, | 94 | 43 | req, context->requestor_string()); | 95 | 43 | if (!result.ok()) { | 96 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 97 | 0 | return false; | 98 | 0 | } | 99 | 43 | return result.get(); | 100 | 43 | } |
bool yb::tserver::CheckUuidMatchOrRespond<yb::tablet::SplitTabletRequestPB, yb::tserver::SplitTabletResponsePB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::tablet::SplitTabletRequestPB const*, yb::tserver::SplitTabletResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 92 | 141 | rpc::RpcContext* context) { | 93 | 141 | Result<bool> result = CheckUuidMatch(tablet_manager, method_name, | 94 | 141 | req, context->requestor_string()); | 95 | 141 | if (!result.ok()) { | 96 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 97 | 0 | return false; | 98 | 0 | } | 99 | 141 | return result.get(); | 100 | 141 | } |
bool yb::tserver::CheckUuidMatchOrRespond<yb::consensus::ConsensusRequestPB, yb::consensus::ConsensusResponsePB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::consensus::ConsensusRequestPB const*, yb::consensus::ConsensusResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 92 | 25.5M | rpc::RpcContext* context) { | 93 | 25.5M | Result<bool> result = CheckUuidMatch(tablet_manager, method_name, | 94 | 25.5M | req, context->requestor_string()); | 95 | 25.5M | if (!result.ok()) { | 96 | 95 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 97 | 95 | return false; | 98 | 95 | } | 99 | 25.5M | return result.get(); | 100 | 25.5M | } |
bool yb::tserver::CheckUuidMatchOrRespond<yb::consensus::VoteRequestPB, yb::consensus::VoteResponsePB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::consensus::VoteRequestPB const*, yb::consensus::VoteResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 92 | 1.39M | rpc::RpcContext* context) { | 93 | 1.39M | Result<bool> result = CheckUuidMatch(tablet_manager, method_name, | 94 | 1.39M | req, context->requestor_string()); | 95 | 1.39M | if (!result.ok()) { | 96 | 2.26k | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 97 | 2.26k | return false; | 98 | 2.26k | } | 99 | 1.39M | return result.get(); | 100 | 1.39M | } |
bool yb::tserver::CheckUuidMatchOrRespond<yb::consensus::ChangeConfigRequestPB, yb::consensus::ChangeConfigResponsePB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::consensus::ChangeConfigRequestPB const*, yb::consensus::ChangeConfigResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 92 | 5.15k | rpc::RpcContext* context) { | 93 | 5.15k | Result<bool> result = CheckUuidMatch(tablet_manager, method_name, | 94 | 5.15k | req, context->requestor_string()); | 95 | 5.15k | if (!result.ok()) { | 96 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 97 | 0 | return false; | 98 | 0 | } | 99 | 5.15k | return result.get(); | 100 | 5.15k | } |
bool yb::tserver::CheckUuidMatchOrRespond<yb::consensus::UnsafeChangeConfigRequestPB, yb::consensus::UnsafeChangeConfigResponsePB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::consensus::UnsafeChangeConfigRequestPB const*, yb::consensus::UnsafeChangeConfigResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 92 | 6 | rpc::RpcContext* context) { | 93 | 6 | Result<bool> result = CheckUuidMatch(tablet_manager, method_name, | 94 | 6 | req, context->requestor_string()); | 95 | 6 | if (!result.ok()) { | 96 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 97 | 0 | return false; | 98 | 0 | } | 99 | 6 | return result.get(); | 100 | 6 | } |
bool yb::tserver::CheckUuidMatchOrRespond<yb::consensus::RunLeaderElectionRequestPB, yb::consensus::RunLeaderElectionResponsePB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::consensus::RunLeaderElectionRequestPB const*, yb::consensus::RunLeaderElectionResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 92 | 96.1k | rpc::RpcContext* context) { | 93 | 96.1k | Result<bool> result = CheckUuidMatch(tablet_manager, method_name, | 94 | 96.1k | req, context->requestor_string()); | 95 | 96.1k | if (!result.ok()) { | 96 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 97 | 0 | return false; | 98 | 0 | } | 99 | 96.1k | return result.get(); | 100 | 96.1k | } |
bool yb::tserver::CheckUuidMatchOrRespond<yb::consensus::LeaderElectionLostRequestPB, yb::consensus::LeaderElectionLostResponsePB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::consensus::LeaderElectionLostRequestPB const*, yb::consensus::LeaderElectionLostResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 92 | 77 | rpc::RpcContext* context) { | 93 | 77 | Result<bool> result = CheckUuidMatch(tablet_manager, method_name, | 94 | 77 | req, context->requestor_string()); | 95 | 77 | if (!result.ok()) { | 96 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 97 | 0 | return false; | 98 | 0 | } | 99 | 77 | return result.get(); | 100 | 77 | } |
bool yb::tserver::CheckUuidMatchOrRespond<yb::consensus::LeaderStepDownRequestPB, yb::consensus::LeaderStepDownResponsePB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::consensus::LeaderStepDownRequestPB const*, yb::consensus::LeaderStepDownResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 92 | 54.1k | rpc::RpcContext* context) { | 93 | 54.1k | Result<bool> result = CheckUuidMatch(tablet_manager, method_name, | 94 | 54.1k | req, context->requestor_string()); | 95 | 54.1k | if (!result.ok()) { | 96 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 97 | 0 | return false; | 98 | 0 | } | 99 | 54.1k | return result.get(); | 100 | 54.1k | } |
bool yb::tserver::CheckUuidMatchOrRespond<yb::consensus::GetLastOpIdRequestPB, yb::consensus::GetLastOpIdResponsePB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::consensus::GetLastOpIdRequestPB const*, yb::consensus::GetLastOpIdResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 92 | 575 | rpc::RpcContext* context) { | 93 | 575 | Result<bool> result = CheckUuidMatch(tablet_manager, method_name, | 94 | 575 | req, context->requestor_string()); | 95 | 575 | if (!result.ok()) { | 96 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 97 | 0 | return false; | 98 | 0 | } | 99 | 575 | return result.get(); | 100 | 575 | } |
bool yb::tserver::CheckUuidMatchOrRespond<yb::consensus::GetConsensusStateRequestPB, yb::consensus::GetConsensusStateResponsePB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::consensus::GetConsensusStateRequestPB const*, yb::consensus::GetConsensusStateResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 92 | 4.06k | rpc::RpcContext* context) { | 93 | 4.06k | Result<bool> result = CheckUuidMatch(tablet_manager, method_name, | 94 | 4.06k | req, context->requestor_string()); | 95 | 4.06k | if (!result.ok()) { | 96 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 97 | 0 | return false; | 98 | 0 | } | 99 | 4.06k | return result.get(); | 100 | 4.06k | } |
bool yb::tserver::CheckUuidMatchOrRespond<yb::consensus::StartRemoteBootstrapRequestPB, yb::consensus::StartRemoteBootstrapResponsePB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::consensus::StartRemoteBootstrapRequestPB const*, yb::consensus::StartRemoteBootstrapResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 92 | 10.6k | rpc::RpcContext* context) { | 93 | 10.6k | Result<bool> result = CheckUuidMatch(tablet_manager, method_name, | 94 | 10.6k | req, context->requestor_string()); | 95 | 10.6k | if (!result.ok()) { | 96 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 97 | 0 | return false; | 98 | 0 | } | 99 | 10.6k | return result.get(); | 100 | 10.6k | } |
bool yb::tserver::CheckUuidMatchOrRespond<yb::tserver::TabletSnapshotOpRequestPB, yb::tserver::TabletSnapshotOpResponsePB>(yb::tserver::TabletPeerLookupIf*, char const*, yb::tserver::TabletSnapshotOpRequestPB const*, yb::tserver::TabletSnapshotOpResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 92 | 55 | rpc::RpcContext* context) { | 93 | 55 | Result<bool> result = CheckUuidMatch(tablet_manager, method_name, | 94 | 55 | req, context->requestor_string()); | 95 | 55 | if (!result.ok()) { | 96 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 97 | 0 | return false; | 98 | 0 | } | 99 | 55 | return result.get(); | 100 | 55 | } |
|
101 | | |
102 | | template <class RespType> |
103 | | void HandleErrorResponse(RespType* resp, rpc::RpcContext* context, const Status& s, |
104 | 3.69k | const boost::optional<TabletServerErrorPB::Code>& error_code = boost::none) { |
105 | 3.69k | resp->Clear(); |
106 | 3.69k | SetupErrorAndRespond(resp->mutable_error(), s, |
107 | 3.69k | error_code.get_value_or(TabletServerErrorPB::UNKNOWN_ERROR), context); |
108 | 3.69k | } void yb::tserver::HandleErrorResponse<yb::tserver::DeleteTabletResponsePB>(yb::tserver::DeleteTabletResponsePB*, yb::rpc::RpcContext*, yb::Status const&, boost::optional<yb::tserver::TabletServerErrorPB_Code> const&) Line | Count | Source | 104 | 2.00k | const boost::optional<TabletServerErrorPB::Code>& error_code = boost::none) { | 105 | 2.00k | resp->Clear(); | 106 | 2.00k | SetupErrorAndRespond(resp->mutable_error(), s, | 107 | 2.00k | error_code.get_value_or(TabletServerErrorPB::UNKNOWN_ERROR), context); | 108 | 2.00k | } |
void yb::tserver::HandleErrorResponse<yb::consensus::ChangeConfigResponsePB>(yb::consensus::ChangeConfigResponsePB*, yb::rpc::RpcContext*, yb::Status const&, boost::optional<yb::tserver::TabletServerErrorPB_Code> const&) Line | Count | Source | 104 | 1.69k | const boost::optional<TabletServerErrorPB::Code>& error_code = boost::none) { | 105 | 1.69k | resp->Clear(); | 106 | 1.69k | SetupErrorAndRespond(resp->mutable_error(), s, | 107 | 1.69k | error_code.get_value_or(TabletServerErrorPB::UNKNOWN_ERROR), context); | 108 | 1.69k | } |
Unexecuted instantiation: void yb::tserver::HandleErrorResponse<yb::consensus::UnsafeChangeConfigResponsePB>(yb::consensus::UnsafeChangeConfigResponsePB*, yb::rpc::RpcContext*, yb::Status const&, boost::optional<yb::tserver::TabletServerErrorPB_Code> const&) Unexecuted instantiation: void yb::tserver::HandleErrorResponse<yb::consensus::GetLastOpIdResponsePB>(yb::consensus::GetLastOpIdResponsePB*, yb::rpc::RpcContext*, yb::Status const&, boost::optional<yb::tserver::TabletServerErrorPB_Code> const&) Unexecuted instantiation: void yb::tserver::HandleErrorResponse<yb::consensus::GetConsensusStateResponsePB>(yb::consensus::GetConsensusStateResponsePB*, yb::rpc::RpcContext*, yb::Status const&, boost::optional<yb::tserver::TabletServerErrorPB_Code> const&) |
109 | | |
110 | | template <class RespType> |
111 | | void HandleResponse(RespType* resp, |
112 | | const std::shared_ptr<rpc::RpcContext>& context, |
113 | 3.61k | const Status& s) { |
114 | 3.61k | if (PREDICT_FALSE(!s.ok())) { |
115 | 15 | HandleErrorResponse(resp, context.get(), s); |
116 | 15 | return; |
117 | 15 | } |
118 | 3.60k | context->RespondSuccess(); |
119 | 3.60k | } |
120 | | |
121 | | template <class RespType> |
122 | | StdStatusCallback BindHandleResponse(RespType* resp, |
123 | 5.29k | const std::shared_ptr<rpc::RpcContext>& context) { |
124 | 5.29k | return std::bind(&HandleResponse<RespType>, resp, context, std::placeholders::_1); |
125 | 5.29k | } |
126 | | |
127 | | struct TabletPeerTablet { |
128 | | std::shared_ptr<tablet::TabletPeer> tablet_peer; |
129 | | tablet::TabletPtr tablet; |
130 | | }; |
131 | | |
132 | | // Lookup the given tablet, ensuring that it both exists and is RUNNING. |
133 | | // If it is not, respond to the RPC associated with 'context' after setting |
134 | | // resp->mutable_error() to indicate the failure reason. |
135 | | // |
136 | | // Returns true if successful. |
137 | | Result<TabletPeerTablet> LookupTabletPeer( |
138 | | TabletPeerLookupIf* tablet_manager, |
139 | | const TabletId& tablet_id); |
140 | | |
141 | | template<class RespClass> |
142 | | Result<TabletPeerTablet> LookupTabletPeerOrRespond( |
143 | | TabletPeerLookupIf* tablet_manager, |
144 | | const string& tablet_id, |
145 | | RespClass* resp, |
146 | 28.0M | rpc::RpcContext* context) { |
147 | 28.0M | Result<TabletPeerTablet> result = LookupTabletPeer(tablet_manager, tablet_id); |
148 | 28.0M | if (!result.ok()) { |
149 | 85.3k | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); |
150 | 85.3k | return result.status(); |
151 | 85.3k | } |
152 | 27.9M | return result.get(); |
153 | 28.0M | } Unexecuted instantiation: yb::Result<yb::tserver::TabletPeerTablet> yb::tserver::LookupTabletPeerOrRespond<yb::tserver::VerifyTableRowRangeResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::tserver::VerifyTableRowRangeResponsePB*, yb::rpc::RpcContext*) yb::Result<yb::tserver::TabletPeerTablet> yb::tserver::LookupTabletPeerOrRespond<yb::tserver::UpdateTransactionResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::tserver::UpdateTransactionResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 146 | 926k | rpc::RpcContext* context) { | 147 | 926k | Result<TabletPeerTablet> result = LookupTabletPeer(tablet_manager, tablet_id); | 148 | 926k | if (!result.ok()) { | 149 | 132 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 150 | 132 | return result.status(); | 151 | 132 | } | 152 | 926k | return result.get(); | 153 | 926k | } |
yb::Result<yb::tserver::TabletPeerTablet> yb::tserver::LookupTabletPeerOrRespond<yb::tserver::FlushTabletsResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::tserver::FlushTabletsResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 146 | 50 | rpc::RpcContext* context) { | 147 | 50 | Result<TabletPeerTablet> result = LookupTabletPeer(tablet_manager, tablet_id); | 148 | 50 | if (!result.ok()) { | 149 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 150 | 0 | return result.status(); | 151 | 0 | } | 152 | 50 | return result.get(); | 153 | 50 | } |
yb::Result<yb::tserver::TabletPeerTablet> yb::tserver::LookupTabletPeerOrRespond<yb::consensus::ConsensusResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::consensus::ConsensusResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 146 | 25.5M | rpc::RpcContext* context) { | 147 | 25.5M | Result<TabletPeerTablet> result = LookupTabletPeer(tablet_manager, tablet_id); | 148 | 25.5M | if (!result.ok()) { | 149 | 17.0k | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 150 | 17.0k | return result.status(); | 151 | 17.0k | } | 152 | 25.5M | return result.get(); | 153 | 25.5M | } |
yb::Result<yb::tserver::TabletPeerTablet> yb::tserver::LookupTabletPeerOrRespond<yb::consensus::VoteResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::consensus::VoteResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 146 | 1.39M | rpc::RpcContext* context) { | 147 | 1.39M | Result<TabletPeerTablet> result = LookupTabletPeer(tablet_manager, tablet_id); | 148 | 1.39M | if (!result.ok()) { | 149 | 29.7k | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 150 | 29.7k | return result.status(); | 151 | 29.7k | } | 152 | 1.36M | return result.get(); | 153 | 1.39M | } |
yb::Result<yb::tserver::TabletPeerTablet> yb::tserver::LookupTabletPeerOrRespond<yb::consensus::ChangeConfigResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::consensus::ChangeConfigResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 146 | 5.27k | rpc::RpcContext* context) { | 147 | 5.27k | Result<TabletPeerTablet> result = LookupTabletPeer(tablet_manager, tablet_id); | 148 | 5.27k | if (!result.ok()) { | 149 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 150 | 0 | return result.status(); | 151 | 0 | } | 152 | 5.27k | return result.get(); | 153 | 5.27k | } |
yb::Result<yb::tserver::TabletPeerTablet> yb::tserver::LookupTabletPeerOrRespond<yb::consensus::UnsafeChangeConfigResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::consensus::UnsafeChangeConfigResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 146 | 6 | rpc::RpcContext* context) { | 147 | 6 | Result<TabletPeerTablet> result = LookupTabletPeer(tablet_manager, tablet_id); | 148 | 6 | if (!result.ok()) { | 149 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 150 | 0 | return result.status(); | 151 | 0 | } | 152 | 6 | return result.get(); | 153 | 6 | } |
yb::Result<yb::tserver::TabletPeerTablet> yb::tserver::LookupTabletPeerOrRespond<yb::consensus::RunLeaderElectionResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::consensus::RunLeaderElectionResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 146 | 96.1k | rpc::RpcContext* context) { | 147 | 96.1k | Result<TabletPeerTablet> result = LookupTabletPeer(tablet_manager, tablet_id); | 148 | 96.1k | if (!result.ok()) { | 149 | 38.2k | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 150 | 38.2k | return result.status(); | 151 | 38.2k | } | 152 | 57.8k | return result.get(); | 153 | 96.1k | } |
yb::Result<yb::tserver::TabletPeerTablet> yb::tserver::LookupTabletPeerOrRespond<yb::consensus::LeaderElectionLostResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::consensus::LeaderElectionLostResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 146 | 77 | rpc::RpcContext* context) { | 147 | 77 | Result<TabletPeerTablet> result = LookupTabletPeer(tablet_manager, tablet_id); | 148 | 77 | if (!result.ok()) { | 149 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 150 | 0 | return result.status(); | 151 | 0 | } | 152 | 77 | return result.get(); | 153 | 77 | } |
yb::Result<yb::tserver::TabletPeerTablet> yb::tserver::LookupTabletPeerOrRespond<yb::consensus::LeaderStepDownResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::consensus::LeaderStepDownResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 146 | 54.1k | rpc::RpcContext* context) { | 147 | 54.1k | Result<TabletPeerTablet> result = LookupTabletPeer(tablet_manager, tablet_id); | 148 | 54.1k | if (!result.ok()) { | 149 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 150 | 0 | return result.status(); | 151 | 0 | } | 152 | 54.1k | return result.get(); | 153 | 54.1k | } |
yb::Result<yb::tserver::TabletPeerTablet> yb::tserver::LookupTabletPeerOrRespond<yb::consensus::GetLastOpIdResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::consensus::GetLastOpIdResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 146 | 575 | rpc::RpcContext* context) { | 147 | 575 | Result<TabletPeerTablet> result = LookupTabletPeer(tablet_manager, tablet_id); | 148 | 575 | if (!result.ok()) { | 149 | 19 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 150 | 19 | return result.status(); | 151 | 19 | } | 152 | 556 | return result.get(); | 153 | 575 | } |
yb::Result<yb::tserver::TabletPeerTablet> yb::tserver::LookupTabletPeerOrRespond<yb::consensus::GetConsensusStateResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::consensus::GetConsensusStateResponsePB*, yb::rpc::RpcContext*) Line | Count | Source | 146 | 4.06k | rpc::RpcContext* context) { | 147 | 4.06k | Result<TabletPeerTablet> result = LookupTabletPeer(tablet_manager, tablet_id); | 148 | 4.06k | if (!result.ok()) { | 149 | 181 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 150 | 181 | return result.status(); | 151 | 181 | } | 152 | 3.88k | return result.get(); | 153 | 4.06k | } |
Unexecuted instantiation: yb::Result<yb::tserver::TabletPeerTablet> yb::tserver::LookupTabletPeerOrRespond<yb::tserver::ImportDataResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::tserver::ImportDataResponsePB*, yb::rpc::RpcContext*) |
154 | | |
155 | | template <class Response> |
156 | | auto MakeRpcOperationCompletionCallback( |
157 | | rpc::RpcContext context, |
158 | | Response* response, |
159 | 12.0M | const server::ClockPtr& clock) { |
160 | 12.0M | return [context = std::make_shared<rpc::RpcContext>(std::move(context)), |
161 | 12.0M | response, clock](const Status& status) { |
162 | 12.0M | if (clock) { |
163 | 12.0M | response->set_propagated_hybrid_time(clock->Now().ToUint64()); |
164 | 12.0M | } |
165 | 12.0M | if (!status.ok()) { |
166 | 64.8k | SetupErrorAndRespond(response->mutable_error(), status, context.get()); |
167 | 11.9M | } else { |
168 | 11.9M | context->RespondSuccess(); |
169 | 11.9M | } |
170 | 12.0M | }; auto yb::tserver::MakeRpcOperationCompletionCallback<yb::tserver::ReadResponsePB>(yb::rpc::RpcContext, yb::tserver::ReadResponsePB*, scoped_refptr<yb::server::Clock> const&)::'lambda'(yb::Status const&)::operator()('lambda'(yb::Status const&)) const Line | Count | Source | 161 | 9.42M | response, clock](const Status& status) { | 162 | 9.42M | if (clock) { | 163 | 9.41M | response->set_propagated_hybrid_time(clock->Now().ToUint64()); | 164 | 9.41M | } | 165 | 9.42M | if (!status.ok()) { | 166 | 0 | SetupErrorAndRespond(response->mutable_error(), status, context.get()); | 167 | 9.42M | } else { | 168 | 9.42M | context->RespondSuccess(); | 169 | 9.42M | } | 170 | 9.42M | }; |
auto yb::tserver::MakeRpcOperationCompletionCallback<yb::tserver::WriteResponsePB>(yb::rpc::RpcContext, yb::tserver::WriteResponsePB*, scoped_refptr<yb::server::Clock> const&)::'lambda'(yb::Status const&)::operator()('lambda'(yb::Status const&)) const Line | Count | Source | 161 | 1 | response, clock](const Status& status) { | 162 | 1 | if (clock) { | 163 | 1 | response->set_propagated_hybrid_time(clock->Now().ToUint64()); | 164 | 1 | } | 165 | 1 | if (!status.ok()) { | 166 | 0 | SetupErrorAndRespond(response->mutable_error(), status, context.get()); | 167 | 1 | } else { | 168 | 1 | context->RespondSuccess(); | 169 | 1 | } | 170 | 1 | }; |
auto yb::tserver::MakeRpcOperationCompletionCallback<yb::tserver::ChangeMetadataResponsePB>(yb::rpc::RpcContext, yb::tserver::ChangeMetadataResponsePB*, scoped_refptr<yb::server::Clock> const&)::'lambda'(yb::Status const&)::operator()('lambda'(yb::Status const&)) const Line | Count | Source | 161 | 31.3k | response, clock](const Status& status) { | 162 | 31.3k | if (clock) { | 163 | 31.3k | response->set_propagated_hybrid_time(clock->Now().ToUint64()); | 164 | 31.3k | } | 165 | 31.3k | if (!status.ok()) { | 166 | 10 | SetupErrorAndRespond(response->mutable_error(), status, context.get()); | 167 | 31.3k | } else { | 168 | 31.3k | context->RespondSuccess(); | 169 | 31.3k | } | 170 | 31.3k | }; |
auto yb::tserver::MakeRpcOperationCompletionCallback<yb::tserver::UpdateTransactionResponsePB>(yb::rpc::RpcContext, yb::tserver::UpdateTransactionResponsePB*, scoped_refptr<yb::server::Clock> const&)::'lambda'(yb::Status const&)::operator()('lambda'(yb::Status const&)) const Line | Count | Source | 161 | 2.52M | response, clock](const Status& status) { | 162 | 2.52M | if (clock) { | 163 | 2.52M | response->set_propagated_hybrid_time(clock->Now().ToUint64()); | 164 | 2.52M | } | 165 | 2.52M | if (!status.ok()) { | 166 | 64.8k | SetupErrorAndRespond(response->mutable_error(), status, context.get()); | 167 | 2.46M | } else { | 168 | 2.46M | context->RespondSuccess(); | 169 | 2.46M | } | 170 | 2.52M | }; |
auto yb::tserver::MakeRpcOperationCompletionCallback<yb::tserver::TruncateResponsePB>(yb::rpc::RpcContext, yb::tserver::TruncateResponsePB*, scoped_refptr<yb::server::Clock> const&)::'lambda'(yb::Status const&)::operator()('lambda'(yb::Status const&)) const Line | Count | Source | 161 | 57.2k | response, clock](const Status& status) { | 162 | 57.2k | if (clock) { | 163 | 57.2k | response->set_propagated_hybrid_time(clock->Now().ToUint64()); | 164 | 57.2k | } | 165 | 57.2k | if (!status.ok()) { | 166 | 5 | SetupErrorAndRespond(response->mutable_error(), status, context.get()); | 167 | 57.2k | } else { | 168 | 57.2k | context->RespondSuccess(); | 169 | 57.2k | } | 170 | 57.2k | }; |
auto yb::tserver::MakeRpcOperationCompletionCallback<yb::tserver::SplitTabletResponsePB>(yb::rpc::RpcContext, yb::tserver::SplitTabletResponsePB*, scoped_refptr<yb::server::Clock> const&)::'lambda'(yb::Status const&)::operator()('lambda'(yb::Status const&)) const Line | Count | Source | 161 | 44 | response, clock](const Status& status) { | 162 | 44 | if (clock) { | 163 | 44 | response->set_propagated_hybrid_time(clock->Now().ToUint64()); | 164 | 44 | } | 165 | 44 | if (!status.ok()) { | 166 | 0 | SetupErrorAndRespond(response->mutable_error(), status, context.get()); | 167 | 44 | } else { | 168 | 44 | context->RespondSuccess(); | 169 | 44 | } | 170 | 44 | }; |
auto yb::tserver::MakeRpcOperationCompletionCallback<yb::tserver::TabletSnapshotOpResponsePB>(yb::rpc::RpcContext, yb::tserver::TabletSnapshotOpResponsePB*, scoped_refptr<yb::server::Clock> const&)::'lambda'(yb::Status const&)::operator()('lambda'(yb::Status const&)) const Line | Count | Source | 161 | 48 | response, clock](const Status& status) { | 162 | 48 | if (clock) { | 163 | 48 | response->set_propagated_hybrid_time(clock->Now().ToUint64()); | 164 | 48 | } | 165 | 48 | if (!status.ok()) { | 166 | 0 | SetupErrorAndRespond(response->mutable_error(), status, context.get()); | 167 | 48 | } else { | 168 | 48 | context->RespondSuccess(); | 169 | 48 | } | 170 | 48 | }; |
|
171 | 12.0M | } auto yb::tserver::MakeRpcOperationCompletionCallback<yb::tserver::ReadResponsePB>(yb::rpc::RpcContext, yb::tserver::ReadResponsePB*, scoped_refptr<yb::server::Clock> const&) Line | Count | Source | 159 | 9.44M | const server::ClockPtr& clock) { | 160 | 9.44M | return [context = std::make_shared<rpc::RpcContext>(std::move(context)), | 161 | 9.44M | response, clock](const Status& status) { | 162 | 9.44M | if (clock) { | 163 | 9.44M | response->set_propagated_hybrid_time(clock->Now().ToUint64()); | 164 | 9.44M | } | 165 | 9.44M | if (!status.ok()) { | 166 | 9.44M | SetupErrorAndRespond(response->mutable_error(), status, context.get()); | 167 | 9.44M | } else { | 168 | 9.44M | context->RespondSuccess(); | 169 | 9.44M | } | 170 | 9.44M | }; | 171 | 9.44M | } |
auto yb::tserver::MakeRpcOperationCompletionCallback<yb::tserver::ChangeMetadataResponsePB>(yb::rpc::RpcContext, yb::tserver::ChangeMetadataResponsePB*, scoped_refptr<yb::server::Clock> const&) Line | Count | Source | 159 | 31.3k | const server::ClockPtr& clock) { | 160 | 31.3k | return [context = std::make_shared<rpc::RpcContext>(std::move(context)), | 161 | 31.3k | response, clock](const Status& status) { | 162 | 31.3k | if (clock) { | 163 | 31.3k | response->set_propagated_hybrid_time(clock->Now().ToUint64()); | 164 | 31.3k | } | 165 | 31.3k | if (!status.ok()) { | 166 | 31.3k | SetupErrorAndRespond(response->mutable_error(), status, context.get()); | 167 | 31.3k | } else { | 168 | 31.3k | context->RespondSuccess(); | 169 | 31.3k | } | 170 | 31.3k | }; | 171 | 31.3k | } |
auto yb::tserver::MakeRpcOperationCompletionCallback<yb::tserver::UpdateTransactionResponsePB>(yb::rpc::RpcContext, yb::tserver::UpdateTransactionResponsePB*, scoped_refptr<yb::server::Clock> const&) Line | Count | Source | 159 | 2.52M | const server::ClockPtr& clock) { | 160 | 2.52M | return [context = std::make_shared<rpc::RpcContext>(std::move(context)), | 161 | 2.52M | response, clock](const Status& status) { | 162 | 2.52M | if (clock) { | 163 | 2.52M | response->set_propagated_hybrid_time(clock->Now().ToUint64()); | 164 | 2.52M | } | 165 | 2.52M | if (!status.ok()) { | 166 | 2.52M | SetupErrorAndRespond(response->mutable_error(), status, context.get()); | 167 | 2.52M | } else { | 168 | 2.52M | context->RespondSuccess(); | 169 | 2.52M | } | 170 | 2.52M | }; | 171 | 2.52M | } |
auto yb::tserver::MakeRpcOperationCompletionCallback<yb::tserver::TruncateResponsePB>(yb::rpc::RpcContext, yb::tserver::TruncateResponsePB*, scoped_refptr<yb::server::Clock> const&) Line | Count | Source | 159 | 57.1k | const server::ClockPtr& clock) { | 160 | 57.1k | return [context = std::make_shared<rpc::RpcContext>(std::move(context)), | 161 | 57.1k | response, clock](const Status& status) { | 162 | 57.1k | if (clock) { | 163 | 57.1k | response->set_propagated_hybrid_time(clock->Now().ToUint64()); | 164 | 57.1k | } | 165 | 57.1k | if (!status.ok()) { | 166 | 57.1k | SetupErrorAndRespond(response->mutable_error(), status, context.get()); | 167 | 57.1k | } else { | 168 | 57.1k | context->RespondSuccess(); | 169 | 57.1k | } | 170 | 57.1k | }; | 171 | 57.1k | } |
auto yb::tserver::MakeRpcOperationCompletionCallback<yb::tserver::SplitTabletResponsePB>(yb::rpc::RpcContext, yb::tserver::SplitTabletResponsePB*, scoped_refptr<yb::server::Clock> const&) Line | Count | Source | 159 | 45 | const server::ClockPtr& clock) { | 160 | 45 | return [context = std::make_shared<rpc::RpcContext>(std::move(context)), | 161 | 45 | response, clock](const Status& status) { | 162 | 45 | if (clock) { | 163 | 45 | response->set_propagated_hybrid_time(clock->Now().ToUint64()); | 164 | 45 | } | 165 | 45 | if (!status.ok()) { | 166 | 45 | SetupErrorAndRespond(response->mutable_error(), status, context.get()); | 167 | 45 | } else { | 168 | 45 | context->RespondSuccess(); | 169 | 45 | } | 170 | 45 | }; | 171 | 45 | } |
auto yb::tserver::MakeRpcOperationCompletionCallback<yb::tserver::WriteResponsePB>(yb::rpc::RpcContext, yb::tserver::WriteResponsePB*, scoped_refptr<yb::server::Clock> const&) Line | Count | Source | 159 | 1 | const server::ClockPtr& clock) { | 160 | 1 | return [context = std::make_shared<rpc::RpcContext>(std::move(context)), | 161 | 1 | response, clock](const Status& status) { | 162 | 1 | if (clock) { | 163 | 1 | response->set_propagated_hybrid_time(clock->Now().ToUint64()); | 164 | 1 | } | 165 | 1 | if (!status.ok()) { | 166 | 1 | SetupErrorAndRespond(response->mutable_error(), status, context.get()); | 167 | 1 | } else { | 168 | 1 | context->RespondSuccess(); | 169 | 1 | } | 170 | 1 | }; | 171 | 1 | } |
auto yb::tserver::MakeRpcOperationCompletionCallback<yb::tserver::TabletSnapshotOpResponsePB>(yb::rpc::RpcContext, yb::tserver::TabletSnapshotOpResponsePB*, scoped_refptr<yb::server::Clock> const&) Line | Count | Source | 159 | 48 | const server::ClockPtr& clock) { | 160 | 48 | return [context = std::make_shared<rpc::RpcContext>(std::move(context)), | 161 | 48 | response, clock](const Status& status) { | 162 | 48 | if (clock) { | 163 | 48 | response->set_propagated_hybrid_time(clock->Now().ToUint64()); | 164 | 48 | } | 165 | 48 | if (!status.ok()) { | 166 | 48 | SetupErrorAndRespond(response->mutable_error(), status, context.get()); | 167 | 48 | } else { | 168 | 48 | context->RespondSuccess(); | 169 | 48 | } | 170 | 48 | }; | 171 | 48 | } |
|
172 | | |
173 | | struct LeaderTabletPeer { |
174 | | tablet::TabletPeerPtr peer; |
175 | | tablet::TabletPtr tablet; |
176 | | int64_t leader_term; |
177 | | |
178 | 5.73M | bool operator!() const { |
179 | 5.73M | return !peer; |
180 | 5.73M | } |
181 | | |
182 | | CHECKED_STATUS FillTerm(); |
183 | | void FillTabletPeer(TabletPeerTablet source); |
184 | | }; |
185 | | |
186 | | Result<LeaderTabletPeer> LookupLeaderTablet( |
187 | | TabletPeerLookupIf* tablet_manager, |
188 | | const std::string& tablet_id, |
189 | | TabletPeerTablet peer = TabletPeerTablet()); |
190 | | |
191 | | // The "peer" argument could be provided by the caller in case the caller has already performed |
192 | | // the LookupTabletPeerOrRespond call, and we only need to fill the leader term. |
193 | | template<class RespClass> |
194 | | LeaderTabletPeer LookupLeaderTabletOrRespond( |
195 | | TabletPeerLookupIf* tablet_manager, |
196 | | const std::string& tablet_id, |
197 | | RespClass* resp, |
198 | | rpc::RpcContext* context, |
199 | 4.80M | TabletPeerTablet peer = TabletPeerTablet()) { |
200 | 4.80M | auto result = LookupLeaderTablet(tablet_manager, tablet_id, std::move(peer)); |
201 | 4.80M | if (!result.ok()) { |
202 | 62.4k | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); |
203 | 62.4k | return LeaderTabletPeer(); |
204 | 62.4k | } |
205 | | |
206 | 4.74M | resp->clear_error(); |
207 | 4.74M | return *result; |
208 | 4.80M | } yb::tserver::LeaderTabletPeer yb::tserver::LookupLeaderTabletOrRespond<yb::tserver::ChangeMetadataResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::tserver::ChangeMetadataResponsePB*, yb::rpc::RpcContext*, yb::tserver::TabletPeerTablet) Line | Count | Source | 199 | 32.0k | TabletPeerTablet peer = TabletPeerTablet()) { | 200 | 32.0k | auto result = LookupLeaderTablet(tablet_manager, tablet_id, std::move(peer)); | 201 | 32.0k | if (!result.ok()) { | 202 | 605 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 203 | 605 | return LeaderTabletPeer(); | 204 | 605 | } | 205 | | | 206 | 31.3k | resp->clear_error(); | 207 | 31.3k | return *result; | 208 | 32.0k | } |
yb::tserver::LeaderTabletPeer yb::tserver::LookupLeaderTabletOrRespond<yb::tserver::GetSafeTimeResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::tserver::GetSafeTimeResponsePB*, yb::rpc::RpcContext*, yb::tserver::TabletPeerTablet) Line | Count | Source | 199 | 4.38k | TabletPeerTablet peer = TabletPeerTablet()) { | 200 | 4.38k | auto result = LookupLeaderTablet(tablet_manager, tablet_id, std::move(peer)); | 201 | 4.38k | if (!result.ok()) { | 202 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 203 | 0 | return LeaderTabletPeer(); | 204 | 0 | } | 205 | | | 206 | 4.38k | resp->clear_error(); | 207 | 4.38k | return *result; | 208 | 4.38k | } |
yb::tserver::LeaderTabletPeer yb::tserver::LookupLeaderTabletOrRespond<yb::tserver::BackfillIndexResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::tserver::BackfillIndexResponsePB*, yb::rpc::RpcContext*, yb::tserver::TabletPeerTablet) Line | Count | Source | 199 | 4.50k | TabletPeerTablet peer = TabletPeerTablet()) { | 200 | 4.50k | auto result = LookupLeaderTablet(tablet_manager, tablet_id, std::move(peer)); | 201 | 4.50k | if (!result.ok()) { | 202 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 203 | 0 | return LeaderTabletPeer(); | 204 | 0 | } | 205 | | | 206 | 4.50k | resp->clear_error(); | 207 | 4.50k | return *result; | 208 | 4.50k | } |
yb::tserver::LeaderTabletPeer yb::tserver::LookupLeaderTabletOrRespond<yb::tserver::UpdateTransactionResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::tserver::UpdateTransactionResponsePB*, yb::rpc::RpcContext*, yb::tserver::TabletPeerTablet) Line | Count | Source | 199 | 1.60M | TabletPeerTablet peer = TabletPeerTablet()) { | 200 | 1.60M | auto result = LookupLeaderTablet(tablet_manager, tablet_id, std::move(peer)); | 201 | 1.60M | if (!result.ok()) { | 202 | 3.77k | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 203 | 3.77k | return LeaderTabletPeer(); | 204 | 3.77k | } | 205 | | | 206 | 1.60M | resp->clear_error(); | 207 | 1.60M | return *result; | 208 | 1.60M | } |
yb::tserver::LeaderTabletPeer yb::tserver::LookupLeaderTabletOrRespond<yb::tserver::GetTransactionStatusResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::tserver::GetTransactionStatusResponsePB*, yb::rpc::RpcContext*, yb::tserver::TabletPeerTablet) Line | Count | Source | 199 | 296k | TabletPeerTablet peer = TabletPeerTablet()) { | 200 | 296k | auto result = LookupLeaderTablet(tablet_manager, tablet_id, std::move(peer)); | 201 | 296k | if (!result.ok()) { | 202 | 223 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 203 | 223 | return LeaderTabletPeer(); | 204 | 223 | } | 205 | | | 206 | 296k | resp->clear_error(); | 207 | 296k | return *result; | 208 | 296k | } |
Unexecuted instantiation: yb::tserver::LeaderTabletPeer yb::tserver::LookupLeaderTabletOrRespond<yb::tserver::GetTransactionStatusAtParticipantResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::tserver::GetTransactionStatusAtParticipantResponsePB*, yb::rpc::RpcContext*, yb::tserver::TabletPeerTablet) yb::tserver::LeaderTabletPeer yb::tserver::LookupLeaderTabletOrRespond<yb::tserver::AbortTransactionResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::tserver::AbortTransactionResponsePB*, yb::rpc::RpcContext*, yb::tserver::TabletPeerTablet) Line | Count | Source | 199 | 193k | TabletPeerTablet peer = TabletPeerTablet()) { | 200 | 193k | auto result = LookupLeaderTablet(tablet_manager, tablet_id, std::move(peer)); | 201 | 193k | if (!result.ok()) { | 202 | 6.74k | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 203 | 6.74k | return LeaderTabletPeer(); | 204 | 6.74k | } | 205 | | | 206 | 186k | resp->clear_error(); | 207 | 186k | return *result; | 208 | 193k | } |
yb::tserver::LeaderTabletPeer yb::tserver::LookupLeaderTabletOrRespond<yb::tserver::TruncateResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::tserver::TruncateResponsePB*, yb::rpc::RpcContext*, yb::tserver::TabletPeerTablet) Line | Count | Source | 199 | 56.9k | TabletPeerTablet peer = TabletPeerTablet()) { | 200 | 56.9k | auto result = LookupLeaderTablet(tablet_manager, tablet_id, std::move(peer)); | 201 | 56.9k | if (!result.ok()) { | 202 | 5 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 203 | 5 | return LeaderTabletPeer(); | 204 | 5 | } | 205 | | | 206 | 56.9k | resp->clear_error(); | 207 | 56.9k | return *result; | 208 | 56.9k | } |
yb::tserver::LeaderTabletPeer yb::tserver::LookupLeaderTabletOrRespond<yb::tserver::AddTableToTabletResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::tserver::AddTableToTabletResponsePB*, yb::rpc::RpcContext*, yb::tserver::TabletPeerTablet) Line | Count | Source | 199 | 126 | TabletPeerTablet peer = TabletPeerTablet()) { | 200 | 126 | auto result = LookupLeaderTablet(tablet_manager, tablet_id, std::move(peer)); | 201 | 126 | if (!result.ok()) { | 202 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 203 | 0 | return LeaderTabletPeer(); | 204 | 0 | } | 205 | | | 206 | 126 | resp->clear_error(); | 207 | 126 | return *result; | 208 | 126 | } |
yb::tserver::LeaderTabletPeer yb::tserver::LookupLeaderTabletOrRespond<yb::tserver::RemoveTableFromTabletResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::tserver::RemoveTableFromTabletResponsePB*, yb::rpc::RpcContext*, yb::tserver::TabletPeerTablet) Line | Count | Source | 199 | 81 | TabletPeerTablet peer = TabletPeerTablet()) { | 200 | 81 | auto result = LookupLeaderTablet(tablet_manager, tablet_id, std::move(peer)); | 201 | 81 | if (!result.ok()) { | 202 | 1 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 203 | 1 | return LeaderTabletPeer(); | 204 | 1 | } | 205 | | | 206 | 80 | resp->clear_error(); | 207 | 80 | return *result; | 208 | 81 | } |
yb::tserver::LeaderTabletPeer yb::tserver::LookupLeaderTabletOrRespond<yb::tserver::SplitTabletResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::tserver::SplitTabletResponsePB*, yb::rpc::RpcContext*, yb::tserver::TabletPeerTablet) Line | Count | Source | 199 | 141 | TabletPeerTablet peer = TabletPeerTablet()) { | 200 | 141 | auto result = LookupLeaderTablet(tablet_manager, tablet_id, std::move(peer)); | 201 | 141 | if (!result.ok()) { | 202 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 203 | 0 | return LeaderTabletPeer(); | 204 | 0 | } | 205 | | | 206 | 141 | resp->clear_error(); | 207 | 141 | return *result; | 208 | 141 | } |
yb::tserver::LeaderTabletPeer yb::tserver::LookupLeaderTabletOrRespond<yb::tserver::WriteResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::tserver::WriteResponsePB*, yb::rpc::RpcContext*, yb::tserver::TabletPeerTablet) Line | Count | Source | 199 | 2.61M | TabletPeerTablet peer = TabletPeerTablet()) { | 200 | 2.61M | auto result = LookupLeaderTablet(tablet_manager, tablet_id, std::move(peer)); | 201 | 2.61M | if (!result.ok()) { | 202 | 51.1k | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 203 | 51.1k | return LeaderTabletPeer(); | 204 | 51.1k | } | 205 | | | 206 | 2.56M | resp->clear_error(); | 207 | 2.56M | return *result; | 208 | 2.61M | } |
yb::tserver::LeaderTabletPeer yb::tserver::LookupLeaderTabletOrRespond<yb::tserver::GetSplitKeyResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::tserver::GetSplitKeyResponsePB*, yb::rpc::RpcContext*, yb::tserver::TabletPeerTablet) Line | Count | Source | 199 | 144 | TabletPeerTablet peer = TabletPeerTablet()) { | 200 | 144 | auto result = LookupLeaderTablet(tablet_manager, tablet_id, std::move(peer)); | 201 | 144 | if (!result.ok()) { | 202 | 0 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 203 | 0 | return LeaderTabletPeer(); | 204 | 0 | } | 205 | | | 206 | 144 | resp->clear_error(); | 207 | 144 | return *result; | 208 | 144 | } |
yb::tserver::LeaderTabletPeer yb::tserver::LookupLeaderTabletOrRespond<yb::tserver::TabletSnapshotOpResponsePB>(yb::tserver::TabletPeerLookupIf*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, yb::tserver::TabletSnapshotOpResponsePB*, yb::rpc::RpcContext*, yb::tserver::TabletPeerTablet) Line | Count | Source | 199 | 54 | TabletPeerTablet peer = TabletPeerTablet()) { | 200 | 54 | auto result = LookupLeaderTablet(tablet_manager, tablet_id, std::move(peer)); | 201 | 54 | if (!result.ok()) { | 202 | 6 | SetupErrorAndRespond(resp->mutable_error(), result.status(), context); | 203 | 6 | return LeaderTabletPeer(); | 204 | 6 | } | 205 | | | 206 | 48 | resp->clear_error(); | 207 | 48 | return *result; | 208 | 54 | } |
|
209 | | |
210 | | CHECKED_STATUS CheckPeerIsLeader(const tablet::TabletPeer& tablet_peer); |
211 | | |
212 | | // Checks if the peer is ready for servicing IOs. |
213 | | // allow_split_tablet specifies whether to reject requests to tablets which have been already |
214 | | // split. |
215 | | CHECKED_STATUS CheckPeerIsReady( |
216 | | const tablet::TabletPeer& tablet_peer, AllowSplitTablet allow_split_tablet); |
217 | | |
218 | | Result<std::shared_ptr<tablet::AbstractTablet>> GetTablet( |
219 | | TabletPeerLookupIf* tablet_manager, const TabletId& tablet_id, |
220 | | tablet::TabletPeerPtr tablet_peer, YBConsistencyLevel consistency_level, |
221 | | AllowSplitTablet allow_split_tablet); |
222 | | |
223 | | CHECKED_STATUS CheckWriteThrottling(double score, tablet::TabletPeer* tablet_peer); |
224 | | |
225 | | } // namespace tserver |
226 | | } // namespace yb |
227 | | |
228 | | // Macro helpers. |
229 | | |
230 | | #define RETURN_UNKNOWN_ERROR_IF_NOT_OK(s, resp, context) \ |
231 | 1.36M | do { \ |
232 | 1.36M | Status ss = s; \ |
233 | 1.36M | if (PREDICT_FALSE(!ss.ok())) { \ |
234 | 8 | SetupErrorAndRespond((resp)->mutable_error(), ss, \ |
235 | 8 | (context)); \ |
236 | 8 | return; \ |
237 | 8 | } \ |
238 | 1.36M | } while (01.36M ) |
239 | | |
240 | | #endif // YB_TSERVER_SERVICE_UTIL_H |