Skip to content

Commit 7f08c8e

Browse files
AieeSophie-Xie
andcommitted
Revert pr 3942 (#4075)
Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com>
1 parent 247bb55 commit 7f08c8e

File tree

4 files changed

+5
-72
lines changed

4 files changed

+5
-72
lines changed

src/clients/meta/MetaClient.cpp

-20
Original file line numberDiff line numberDiff line change
@@ -2601,11 +2601,6 @@ folly::Future<StatusOr<bool>> MetaClient::heartbeat() {
26012601
}
26022602
}
26032603

2604-
// TTL for clientAddrMap
2605-
// If multiple connections are created but do not authenticate, the clientAddrMap_ will keep
2606-
// growing. This is to clear the clientAddrMap_ regularly.
2607-
clearClientAddrMap();
2608-
26092604
// info used in the agent, only set once
26102605
// TOOD(spw): if we could add data path(disk) dynamicly in the future, it should be
26112606
// reported every time it changes
@@ -3802,20 +3797,5 @@ Status MetaClient::verifyVersion() {
38023797
return Status::OK();
38033798
}
38043799

3805-
void MetaClient::clearClientAddrMap() {
3806-
if (clientAddrMap_.size() == 0) {
3807-
return;
3808-
}
3809-
3810-
auto curTimestamp = time::WallClock::fastNowInSec();
3811-
for (auto it = clientAddrMap_.cbegin(); it != clientAddrMap_.cend();) {
3812-
// The clientAddr is expired
3813-
if (it->second < curTimestamp) {
3814-
it = clientAddrMap_.erase(it);
3815-
} else {
3816-
++it;
3817-
}
3818-
}
3819-
}
38203800
} // namespace meta
38213801
} // namespace nebula

src/clients/meta/MetaClient.h

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

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

159-
using clientAddrMap = folly::ConcurrentHashMap<HostAddr, int64_t>;
160159
class MetaChangedListener {
161160
public:
162161
virtual ~MetaChangedListener() = default;
@@ -671,10 +670,6 @@ class MetaClient {
671670
return options_.localHost_.toString();
672671
}
673672

674-
clientAddrMap& getClientAddrMap() {
675-
return clientAddrMap_;
676-
}
677-
678673
protected:
679674
// Return true if load succeeded.
680675
bool loadData();
@@ -761,9 +756,6 @@ class MetaClient {
761756

762757
Status verifyVersion();
763758

764-
// Removes expired keys in the clientAddrMap_
765-
void clearClientAddrMap();
766-
767759
private:
768760
std::shared_ptr<folly::IOThreadPoolExecutor> ioThreadPool_;
769761
std::shared_ptr<thrift::ThriftClientManager<cpp2::MetaServiceAsyncClient>> clientsMan_;
@@ -844,18 +836,6 @@ class MetaClient {
844836
NameIndexMap tagNameIndexMap_;
845837
NameIndexMap edgeNameIndexMap_;
846838

847-
// TODO(Aiee) This is a walkaround to address the problem that using a lower version(< v2.6.0)
848-
// client to connect with higher version(>= v3.0.0) Nebula service will cause a crash.
849-
//
850-
// The key here is the host of the client that sends the request, and the value indicates the
851-
// expiration of the key because we don't want to keep the key forever.
852-
//
853-
// The assumption here is that there is ONLY ONE VERSION of the client in the host.
854-
//
855-
// This map will be updated when verifyVersion() is called. Only the clients since v2.6.0 will
856-
// call verifyVersion(), thus we could determine whether the client version is lower than v2.6.0
857-
clientAddrMap clientAddrMap_;
858-
859839
// Global service client
860840
ServiceClientsList serviceClientList_;
861841
FTIndexMap fulltextIndexMap_;

src/graph/service/GraphService.cpp

+4-31
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,8 @@ 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();
214-
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 lower than v2.6.0, "
224-
"please update the client.",
225-
clientIp.toString()));
226-
}
227-
228208
// Skip authentication if FLAGS_enable_authorize is false
229209
if (!FLAGS_enable_authorize) {
230210
return Status::OK();
@@ -266,13 +246,6 @@ folly::Future<cpp2::VerifyClientVersionResp> GraphService::future_verifyClientVe
266246
resp.error_code_ref() = nebula::cpp2::ErrorCode::SUCCEEDED;
267247
}
268248

269-
// The client sent request has a version >= v2.6.0, mark the address as valid
270-
auto* peer = getRequestContext()->getPeerAddress();
271-
auto clientAddr = HostAddr(peer->getAddressStr(), peer->getPort());
272-
273-
auto ttlTimestamp = time::WallClock::fastNowInSec() + clientAddrTimeout;
274-
auto clientAddrMap = &metaClient_->getClientAddrMap();
275-
clientAddrMap->insert_or_assign(clientAddr, ttlTimestamp);
276249
return folly::makeFuture<cpp2::VerifyClientVersionResp>(std::move(resp));
277250
}
278251
} // 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)