Skip to content

Commit aa59808

Browse files
authored
Merge branch 'master' into revert_docker
2 parents b0f19ff + 60cf573 commit aa59808

File tree

4 files changed

+5
-71
lines changed

4 files changed

+5
-71
lines changed

src/clients/meta/MetaClient.cpp

-20
Original file line numberDiff line numberDiff line change
@@ -2484,11 +2484,6 @@ folly::Future<StatusOr<bool>> MetaClient::heartbeat() {
24842484
}
24852485
}
24862486

2487-
// TTL for clientAddrMap
2488-
// If multiple connections are created but do not authenticate, the clientAddrMap_ will keep
2489-
// growing. This is to clear the clientAddrMap_ regularly.
2490-
clearClientAddrMap();
2491-
24922487
// info used in the agent, only set once
24932488
// TOOD(spw): if we could add data path(disk) dynamicly in the future, it should be
24942489
// reported every time it changes
@@ -3658,20 +3653,5 @@ Status MetaClient::verifyVersion() {
36583653
return Status::OK();
36593654
}
36603655

3661-
void MetaClient::clearClientAddrMap() {
3662-
if (clientAddrMap_.size() == 0) {
3663-
return;
3664-
}
3665-
3666-
auto curTimestamp = time::WallClock::fastNowInSec();
3667-
for (auto it = clientAddrMap_.cbegin(); it != clientAddrMap_.cend();) {
3668-
// The clientAddr is expired
3669-
if (it->second < curTimestamp) {
3670-
it = clientAddrMap_.erase(it);
3671-
} else {
3672-
++it;
3673-
}
3674-
}
3675-
}
36763656
} // namespace meta
36773657
} // namespace nebula

src/clients/meta/MetaClient.h

-20
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ using FTIndexMap = std::unordered_map<std::string, cpp2::FTIndex>;
155155

156156
using SessionMap = std::unordered_map<SessionID, cpp2::Session>;
157157

158-
using clientAddrMap = folly::ConcurrentHashMap<HostAddr, int64_t>;
159158
class MetaChangedListener {
160159
public:
161160
virtual ~MetaChangedListener() = default;
@@ -657,10 +656,6 @@ class MetaClient : public BaseMetaClient {
657656
return options_.localHost_.toString();
658657
}
659658

660-
clientAddrMap& getClientAddrMap() {
661-
return clientAddrMap_;
662-
}
663-
664659
protected:
665660
// Return true if load succeeded.
666661
bool loadData();
@@ -747,9 +742,6 @@ class MetaClient : public BaseMetaClient {
747742

748743
Status verifyVersion();
749744

750-
// Removes expired keys in the clientAddrMap_
751-
void clearClientAddrMap();
752-
753745
private:
754746
std::shared_ptr<folly::IOThreadPoolExecutor> ioThreadPool_;
755747
std::shared_ptr<thrift::ThriftClientManager<cpp2::MetaServiceAsyncClient>> clientsMan_;
@@ -830,18 +822,6 @@ class MetaClient : public BaseMetaClient {
830822
NameIndexMap tagNameIndexMap_;
831823
NameIndexMap edgeNameIndexMap_;
832824

833-
// TODO(Aiee) This is a walkaround to address the problem that using a lower version(< v2.6.0)
834-
// client to connect with higher version(>= v3.0.0) Nebula service will cause a crash.
835-
//
836-
// The key here is the host of the client that sends the request, and the value indicates the
837-
// expiration of the key because we don't want to keep the key forever.
838-
//
839-
// The assumption here is that there is ONLY ONE VERSION of the client in the host.
840-
//
841-
// This map will be updated when verifyVersion() is called. Only the clients since v2.6.0 will
842-
// call verifyVersion(), thus we could determine whether the client version is lower than v2.6.0
843-
clientAddrMap clientAddrMap_;
844-
845825
// Global service client
846826
ServiceClientsList serviceClientList_;
847827
FTIndexMap fulltextIndexMap_;

src/graph/service/GraphService.cpp

+4-30
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
namespace nebula {
2525
namespace graph {
2626

27-
// The default value is 28800 seconds
28-
const int64_t clientAddrTimeout = FLAGS_client_idle_timeout_secs;
29-
3027
Status GraphService::init(std::shared_ptr<folly::IOThreadPoolExecutor> ioExecutor,
3128
const HostAddr& hostAddr) {
3229
auto addrs = network::NetworkUtils::toHosts(FLAGS_meta_server_addrs);
@@ -72,10 +69,9 @@ folly::Future<AuthResponse> GraphService::future_authenticate(const std::string&
7269

7370
auto ctx = std::make_unique<RequestContext<AuthResponse>>();
7471
auto future = ctx->future();
75-
// Check username and password failed
76-
// Check whether the client has called verifyClientVersion()
77-
auto clientAddr = HostAddr(peer->getAddressStr(), peer->getPort());
78-
auto authResult = auth(username, password, clientAddr);
72+
73+
// check username and password failed
74+
auto authResult = auth(username, password);
7975
if (!authResult.ok()) {
8076
ctx->resp().errorCode = ErrorCode::E_BAD_USERNAME_PASSWORD;
8177
ctx->resp().errorMsg.reset(new std::string(authResult.toString()));
@@ -207,24 +203,9 @@ folly::Future<std::string> GraphService::future_executeJsonWithParameter(
207203
});
208204
}
209205

210-
Status GraphService::auth(const std::string& username,
211-
const std::string& password,
212-
const HostAddr& clientIp) {
206+
Status GraphService::auth(const std::string& username, const std::string& password) {
213207
auto metaClient = queryEngine_->metaClient();
214208

215-
// TODO(Aiee) This is a walkaround to address the problem that using a lower version(< v2.6.0)
216-
// client to connect with higher version(>= v3.0.0) Nebula service will cause a crash.
217-
//
218-
// Only the clients since v2.6.0 will call verifyVersion(), thus we could determine whether the
219-
// client version is lower than v2.6.0
220-
auto clientAddrIt = metaClient->getClientAddrMap().find(clientIp);
221-
if (clientAddrIt == metaClient->getClientAddrMap().end()) {
222-
return Status::Error(
223-
folly::sformat("The version of the client sending request from {} is too old, "
224-
"please update the client.",
225-
clientIp.toString()));
226-
}
227-
228209
// Skip authentication if FLAGS_enable_authorize is false
229210
if (!FLAGS_enable_authorize) {
230211
return Status::OK();
@@ -270,13 +251,6 @@ folly::Future<cpp2::VerifyClientVersionResp> GraphService::future_verifyClientVe
270251
resp.error_code_ref() = nebula::cpp2::ErrorCode::SUCCEEDED;
271252
}
272253

273-
// The client sent request has a version >= v2.6.0, mark the address as valid
274-
auto* peer = getRequestContext()->getPeerAddress();
275-
auto clientAddr = HostAddr(peer->getAddressStr(), peer->getPort());
276-
277-
auto ttlTimestamp = time::WallClock::fastNowInSec() + clientAddrTimeout;
278-
auto clientAddrMap = &metaClient_->getClientAddrMap();
279-
clientAddrMap->insert_or_assign(clientAddr, ttlTimestamp);
280254
return folly::makeFuture<cpp2::VerifyClientVersionResp>(std::move(resp));
281255
}
282256
} // namespace graph

src/graph/service/GraphService.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class GraphService final : public cpp2::GraphServiceSvIf {
5454
std::unique_ptr<meta::MetaClient> metaClient_;
5555

5656
private:
57-
Status auth(const std::string& username, const std::string& password, const HostAddr& clientIp);
57+
Status auth(const std::string& username, const std::string& password);
5858

5959
std::unique_ptr<GraphSessionManager> sessionManager_;
6060
std::unique_ptr<QueryEngine> queryEngine_;

0 commit comments

Comments
 (0)