Skip to content

Commit 0f8ce2e

Browse files
laura-dingdutor
andauthored
Add warning msg for partially performed (#2290)
* add warning for partially performed * address comment Co-authored-by: dutor <440396+dutor@users.noreply.github.com>
1 parent 6b61835 commit 0f8ce2e

10 files changed

+25
-7
lines changed

src/graph/DropSpaceExecutor.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ void DropSpaceExecutor::execute() {
4040
if (*spaceName_ == ectx()->rctx()->session()->spaceName()) {
4141
ectx()->rctx()->session()->setSpace("", -1);
4242
}
43+
ectx()->addWarningMsg("Data will be deleted completely after restarting the services");
44+
4345
doFinish(Executor::ProcessControl::kNext);
4446
};
4547

@@ -53,9 +55,5 @@ void DropSpaceExecutor::execute() {
5355

5456
std::move(future).via(runner).thenValue(cb).thenError(error);
5557
}
56-
57-
void DropSpaceExecutor::setupResponse(cpp2::ExecutionResponse &resp) {
58-
resp.set_warning_msg("Data will be deleted completely after restarting the services.");
59-
}
6058
} // namespace graph
6159
} // namespace nebula

src/graph/DropSpaceExecutor.h

-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ class DropSpaceExecutor final : public Executor {
2525

2626
void execute() override;
2727

28-
void setupResponse(cpp2::ExecutionResponse &resp) override;
29-
3028
private:
3129
DropSpaceSentence *sentence_{nullptr};
3230
const std::string *spaceName_{nullptr};

src/graph/ExecutionContext.h

+9
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ class ExecutionContext final : public cpp::NonCopyable, public cpp::NonMovable {
7575
return charsetInfo_;
7676
}
7777

78+
void addWarningMsg(std::string msg) {
79+
warnMsgs_.emplace_back(std::move(msg));
80+
}
81+
82+
const std::vector<std::string>& getWarningMsg() const {
83+
return warnMsgs_;
84+
}
85+
7886
private:
7987
RequestContextPtr rctx_;
8088
meta::SchemaManager *sm_{nullptr};
@@ -83,6 +91,7 @@ class ExecutionContext final : public cpp::NonCopyable, public cpp::NonMovable {
8391
meta::MetaClient *metaClient_{nullptr};
8492
std::unique_ptr<VariableHolder> variableHolder_;
8593
CharsetInfo *charsetInfo_{nullptr};
94+
std::vector<std::string> warnMsgs_;
8695
};
8796

8897
} // namespace graph

src/graph/ExecutionPlan.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ void ExecutionPlan::onFinish() {
6262
rctx->resp().set_latency_in_us(latency);
6363
auto &spaceName = rctx->session()->spaceName();
6464
rctx->resp().set_space_name(spaceName);
65+
if (!ectx()->getWarningMsg().empty()) {
66+
rctx->resp().set_warning_msg(
67+
folly::stringPrintf("%s.", folly::join(", ", ectx()->getWarningMsg()).c_str()));
68+
}
6569
rctx->finish();
6670

6771
// The `ExecutionPlan' is the root node holding all resources during the execution.

src/graph/FetchEdgesExecutor.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ void FetchEdgesExecutor::fetchEdges() {
321321
LOG(ERROR) << "part: " << error.first
322322
<< "error code: " << static_cast<int>(error.second);
323323
}
324+
ectx()->addWarningMsg("Fetch edges executor was partially performed");
324325
}
325326
processResult(std::move(result));
326327
return;

src/graph/FetchVerticesExecutor.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ void FetchVerticesExecutor::fetchVertices() {
341341
LOG(ERROR) << "part: " << error.first
342342
<< "error code: " << static_cast<int>(error.second);
343343
}
344+
ectx()->addWarningMsg("Fetch vertices executor was partially performed");
344345
}
345346
processResult(std::move(result));
346347
};

src/graph/FindPathExecutor.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ void FindPathExecutor::getToFrontiers(
520520
LOG(ERROR) << "part: " << error.first
521521
<< "error code: " << static_cast<int>(error.second);
522522
}
523+
ectx()->addWarningMsg("Find path executor was partially performed");
523524
}
524525
auto status = doFilter(std::move(result), where_.filter_, false, frontiers);
525526
if (!status.ok()) {

src/graph/GoExecutor.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ void GoExecutor::stepOut() {
554554
LOG(ERROR) << "part: " << error.first
555555
<< "error code: " << static_cast<int>(error.second);
556556
}
557+
warningMsg_ = "Go executor was partially performed";
557558
}
558559
if (FLAGS_trace_go) {
559560
LOG(INFO) << "Step:" << curStep_
@@ -724,7 +725,9 @@ void GoExecutor::finishExecution() {
724725
yc.emplace_back(std::move(ptr));
725726
}
726727
}
727-
728+
if (!warningMsg_.empty()) {
729+
ectx()->addWarningMsg(warningMsg_);
730+
}
728731

729732
if (onResult_) {
730733
std::unique_ptr<InterimResult> outputs;
@@ -947,6 +950,7 @@ void GoExecutor::fetchVertexProps(std::vector<VertexID> ids) {
947950
LOG(ERROR) << "part: " << error.first
948951
<< "error code: " << static_cast<int>(error.second);
949952
}
953+
warningMsg_ = "Go executor was partially performed";
950954
}
951955
if (vertexHolder_ == nullptr) {
952956
vertexHolder_ = std::make_unique<VertexHolder>(ectx);

src/graph/GoExecutor.h

+1
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ class GoExecutor final : public TraverseExecutor {
246246
std::vector<RpcResponse> records_;
247247
// The name of Tag or Edge, index of prop in data
248248
using SchemaPropIndex = std::unordered_map<std::pair<std::string, std::string>, int64_t>;
249+
std::string warningMsg_;
249250
};
250251

251252
} // namespace graph

src/graph/LookupExecutor.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ void LookupExecutor::lookUp() {
329329
LOG(ERROR) << "part: " << error.first
330330
<< "error code: " << static_cast<int>(error.second);
331331
}
332+
ectx()->addWarningMsg("Lookup executor was partially performed");
332333
}
333334
finishExecution(std::forward<decltype(result)>(result));
334335
};

0 commit comments

Comments
 (0)