-
Notifications
You must be signed in to change notification settings - Fork 37
Slow query. #565
Slow query. #565
Changes from 8 commits
44d61ae
5749e55
fe17005
27ee49d
b066029
459bff9
8dd8642
bd4dd3b
9168f61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1063,6 +1063,20 @@ struct ListFTIndexesResp { | |
3: map<binary, FTIndex> (cpp.template = "std::unordered_map") indexes, | ||
} | ||
|
||
enum QueryStatus { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prefer state than status There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems no difference between these two words? Besides we have a lot struct defined as |
||
RUNNING = 0x01, | ||
KILLING = 0x02, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we not need a finished or stopped state? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The finished queries will be removed. |
||
} (cpp.enum_strict) | ||
|
||
struct QueryDesc { | ||
1: common.Timestamp start_time; | ||
2: QueryStatus status; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
3: i64 duration; | ||
4: binary query; | ||
// The session might transfer between query engines, but the query do not, we must | ||
// record which query engine the query belongs to | ||
5: common.HostAddr graph_addr, | ||
} | ||
|
||
struct Session { | ||
1: common.SessionID session_id, | ||
|
@@ -1074,6 +1088,7 @@ struct Session { | |
7: i32 timezone, | ||
8: binary client_ip, | ||
9: map<binary, common.Value>(cpp.template = "std::unordered_map") configs, | ||
10: map<common.ExecutionPlanID, QueryDesc>(cpp.template = "std::unordered_map") queries; | ||
} | ||
|
||
struct CreateSessionReq { | ||
|
@@ -1092,6 +1107,13 @@ struct UpdateSessionsReq { | |
1: list<Session> sessions, | ||
} | ||
|
||
struct UpdateSessionsResp { | ||
1: common.ErrorCode code, | ||
2: common.HostAddr leader, | ||
3: map<common.SessionID, map<common.ExecutionPlanID, QueryDesc> (cpp.template = "std::unordered_map")> | ||
(cpp.template = "std::unordered_map") killed_queries, | ||
} | ||
|
||
struct ListSessionsReq { | ||
} | ||
|
||
|
@@ -1115,6 +1137,11 @@ struct RemoveSessionReq { | |
1: common.SessionID session_id, | ||
} | ||
|
||
struct KillQueryReq { | ||
1: map<common.SessionID, set<common.ExecutionPlanID> (cpp.template = "std::unordered_set")> | ||
(cpp.template = "std::unordered_map") kill_queries, | ||
} | ||
|
||
struct ReportTaskReq { | ||
1: common.ErrorCode code, | ||
2: i32 job_id, | ||
|
@@ -1238,10 +1265,11 @@ service MetaService { | |
ListFTIndexesResp listFTIndexes(1: ListFTIndexesReq req); | ||
|
||
CreateSessionResp createSession(1: CreateSessionReq req); | ||
ExecResp updateSessions(1: UpdateSessionsReq req); | ||
UpdateSessionsResp updateSessions(1: UpdateSessionsReq req); | ||
ListSessionsResp listSessions(1: ListSessionsReq req); | ||
GetSessionResp getSession(1: GetSessionReq req); | ||
ExecResp removeSession(1: RemoveSessionReq req); | ||
ExecResp killQuery(1: KillQueryReq req); | ||
|
||
ExecResp reportTaskFinish(1: ReportTaskReq req); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* Copyright (c) 2021 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License, | ||
* attached with Common Clause Condition 1.0, found in the LICENSES directory. | ||
*/ | ||
|
||
#ifndef COMMON_SESSION_SESSIONMANAGER_H_ | ||
#define COMMON_SESSION_SESSIONMANAGER_H_ | ||
|
||
#include <folly/concurrency/ConcurrentHashMap.h> | ||
|
||
#include "common/base/Base.h" | ||
#include "common/thrift/ThriftTypes.h" | ||
#include "common/base/StatusOr.h" | ||
#include "common/thread/GenericWorker.h" | ||
#include "common/clients/meta/MetaClient.h" | ||
|
||
|
||
/** | ||
* SessionManager manages the client sessions, e.g. create new, find existing and drop expired. | ||
*/ | ||
|
||
namespace nebula { | ||
|
||
template <class SessionType> | ||
class SessionManager { | ||
public: | ||
SessionManager(meta::MetaClient* metaClient, const HostAddr &hostAddr) { | ||
metaClient_ = metaClient; | ||
myAddr_ = hostAddr; | ||
scavenger_ = std::make_unique<thread::GenericWorker>(); | ||
auto ok = scavenger_->start("session-manager"); | ||
DCHECK(ok); | ||
} | ||
|
||
virtual ~SessionManager() { | ||
if (scavenger_ != nullptr) { | ||
scavenger_->stop(); | ||
scavenger_->wait(); | ||
scavenger_.reset(); | ||
} | ||
} | ||
|
||
/** | ||
* Create a new session | ||
*/ | ||
virtual folly::Future<StatusOr<std::shared_ptr<SessionType>>> | ||
createSession(const std::string userName, | ||
const std::string clientIp, | ||
folly::Executor* runner) = 0; | ||
|
||
/** | ||
* Remove a session | ||
*/ | ||
virtual void removeSession(SessionID id) = 0; | ||
|
||
virtual folly::Future<StatusOr<std::shared_ptr<SessionType>>> | ||
findSession(SessionID id, folly::Executor* runner) = 0; | ||
|
||
protected: | ||
using SessionPtr = std::shared_ptr<SessionType>; | ||
folly::ConcurrentHashMap<SessionID, SessionPtr> activeSessions_; | ||
std::unique_ptr<thread::GenericWorker> scavenger_; | ||
meta::MetaClient *metaClient_{nullptr}; | ||
HostAddr myAddr_; | ||
}; | ||
|
||
} // namespace nebula | ||
|
||
|
||
#endif // COMMON_SESSION_SESSIONMANAGER_H_ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,5 +46,6 @@ using ZoneID = int32_t; | |
|
||
using SessionID = int64_t; | ||
|
||
using ExecutionPlanID = int64_t; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Query id is better than plan id. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For compatibility considered, I want to keep the idea |
||
} // namespace nebula | ||
#endif // COMMON_THRIFT_THRIFTTYPES_H_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to add to
nebula-common/src/common/graph/Response.h