Abort SHOW RAFT INFO
queries
Reviewers: teon.banek, msantl Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1983
This commit is contained in:
parent
cde2875a50
commit
8b7df83473
@ -73,6 +73,7 @@ std::string Interpreter::PlanToJson(const database::GraphDbAccessor &dba,
|
||||
struct Callback {
|
||||
std::vector<std::string> header;
|
||||
std::function<std::vector<std::vector<TypedValue>>()> fn;
|
||||
bool should_abort_query{false};
|
||||
};
|
||||
|
||||
TypedValue EvaluateOptionalExpression(Expression *expression,
|
||||
@ -640,6 +641,9 @@ Callback HandleInfoQuery(InfoQuery *info_query,
|
||||
{"term_id", static_cast<int64_t>(db_accessor->raft()->TermId())}});
|
||||
return results;
|
||||
};
|
||||
// It is critical to abort this query because it can be executed on
|
||||
// machines that aren't the leader.
|
||||
callback.should_abort_query = true;
|
||||
#else
|
||||
throw utils::NotYetImplemented("raft info");
|
||||
#endif
|
||||
@ -896,7 +900,7 @@ Interpreter::Results Interpreter::operator()(
|
||||
|
||||
return Results(&db_accessor, parameters, plan, output_symbols, header,
|
||||
summary, parsed_query.required_privileges,
|
||||
/* is_profile_query */ true);
|
||||
/* is_profile_query */ true, /* should_abort_query */ true);
|
||||
}
|
||||
|
||||
Callback callback;
|
||||
@ -964,7 +968,8 @@ Interpreter::Results Interpreter::operator()(
|
||||
summary["cost_estimate"] = 0.0;
|
||||
|
||||
return Results(&db_accessor, parameters, plan, output_symbols,
|
||||
callback.header, summary, parsed_query.required_privileges);
|
||||
callback.header, summary, parsed_query.required_privileges,
|
||||
/* is_profile_query */ false, callback.should_abort_query);
|
||||
}
|
||||
|
||||
std::shared_ptr<Interpreter::CachedPlan> Interpreter::CypherQueryToPlan(
|
||||
|
@ -90,7 +90,7 @@ class Interpreter {
|
||||
std::vector<Symbol> output_symbols, std::vector<std::string> header,
|
||||
std::map<std::string, TypedValue> summary,
|
||||
std::vector<AuthQuery::Privilege> privileges,
|
||||
bool is_profile_query = false)
|
||||
bool is_profile_query = false, bool should_abort_query = false)
|
||||
: ctx_{db_accessor},
|
||||
plan_(plan),
|
||||
cursor_(plan_->plan().MakeCursor(*db_accessor)),
|
||||
@ -98,7 +98,8 @@ class Interpreter {
|
||||
output_symbols_(output_symbols),
|
||||
header_(header),
|
||||
summary_(summary),
|
||||
privileges_(std::move(privileges)) {
|
||||
privileges_(std::move(privileges)),
|
||||
should_abort_query_(should_abort_query) {
|
||||
ctx_.is_profile_query = is_profile_query;
|
||||
ctx_.symbol_table = plan_->symbol_table();
|
||||
ctx_.evaluation_context.timestamp =
|
||||
@ -170,7 +171,7 @@ class Interpreter {
|
||||
return privileges_;
|
||||
}
|
||||
|
||||
bool IsProfileQuery() const { return ctx_.is_profile_query; }
|
||||
bool ShouldAbortQuery() const { return should_abort_query_; }
|
||||
|
||||
private:
|
||||
ExecutionContext ctx_;
|
||||
@ -185,6 +186,8 @@ class Interpreter {
|
||||
double execution_time_{0};
|
||||
|
||||
std::vector<AuthQuery::Privilege> privileges_;
|
||||
|
||||
bool should_abort_query_;
|
||||
};
|
||||
|
||||
Interpreter();
|
||||
|
@ -88,7 +88,7 @@ class TransactionEngine final {
|
||||
// `results_` object.
|
||||
auto summary = results_->summary();
|
||||
if (!in_explicit_transaction_) {
|
||||
if (results_->IsProfileQuery()) {
|
||||
if (results_->ShouldAbortQuery()) {
|
||||
Abort();
|
||||
} else {
|
||||
Commit();
|
||||
|
Loading…
Reference in New Issue
Block a user