Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
Address comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
CPWstatic committed Jul 1, 2021
1 parent e3eb9b2 commit 04671b5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
37 changes: 15 additions & 22 deletions src/executor/admin/KillQueryExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ folly::Future<Status> KillQueryExecutor::execute() {
QueriesMap killQueries;
NG_RETURN_IF_ERROR(verifyTheQueriesByLocalCache(toBeVerifiedQueries, killQueries));

folly::Promise<Status> pro;
auto result = pro.getFuture();
qctx()->getMetaClient()->listSessions().via(runner()).thenValue(
[toBeVerifiedQueries = std::move(toBeVerifiedQueries),
killQueries = std::move(killQueries),
pro = std::move(pro),
this](StatusOr<meta::cpp2::ListSessionsResp> listResp) mutable {
return qctx()
->getMetaClient()
->listSessions()
.via(runner())
.thenValue([toBeVerifiedQueries = std::move(toBeVerifiedQueries),
killQueries = std::move(killQueries),
this](StatusOr<meta::cpp2::ListSessionsResp> listResp) mutable {
std::vector<meta::cpp2::Session> sessionsInMeta;
if (listResp.ok()) {
sessionsInMeta = std::move(listResp.value()).get_sessions();
Expand All @@ -36,27 +36,20 @@ folly::Future<Status> KillQueryExecutor::execute() {

auto status = verifyTheQueriesByMetaInfo(toBeVerifiedQueries, sessionsInMeta);
if (!status.ok()) {
pro.setValue(std::move(status));
return;
return folly::makeFuture<StatusOr<meta::cpp2::ExecResp>>(status);
}

killCurrentHostQueries(killQueries);

// upload all queries to be killed to meta.
qctx()
->getMetaClient()
->killQuery(std::move(killQueries))
.via(runner())
.thenValue([pro = std::move(pro), this](auto&& resp) mutable {
SCOPED_TIMER(&execTime_);
auto respStatus = Status::OK();
if (!resp.ok()) {
respStatus = resp.status();
}
pro.setValue(std::move(respStatus));
});
return qctx()->getMetaClient()->killQuery(std::move(killQueries));
})
.thenValue([](auto&& resp) {
if (!resp.ok()) {
return resp.status();
}
return Status::OK();
});
return result;
}

Status KillQueryExecutor::verifyTheQueriesByLocalCache(QueriesMap& toBeVerifiedQueries,
Expand Down
1 change: 1 addition & 0 deletions src/session/GraphSessionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ GraphSessionManager::findSessionFromMetad(SessionID id, folly::Executor* runner)
"Session `%ld' not found: %s", id, resp.status().toString().c_str());
}
auto session = resp.value().get_session();
session.queries_ref()->clear();
auto spaceName = session.get_space_name();
SpaceInfo spaceInfo;
if (!spaceName.empty()) {
Expand Down

0 comments on commit 04671b5

Please sign in to comment.