fix issues on memory limit
This commit is contained in:
parent
5385c741ad
commit
6e37b46eee
src/query
@ -1646,7 +1646,6 @@ std::optional<plan::ProfilingStatsWithTotalTime> PullPlan::Pull(AnyStream *strea
|
||||
MG_ASSERT(transaction_id.has_value());
|
||||
|
||||
if (memory_limit_) {
|
||||
std::cout << "Memory tracking transaction id: " << *transaction_id << std::endl;
|
||||
memgraph::memory::TryStartTrackingOnTransaction(*transaction_id, *memory_limit_);
|
||||
memgraph::memory::StartTrackingCurrentThreadTransaction(*transaction_id);
|
||||
}
|
||||
@ -4175,6 +4174,9 @@ Interpreter::PrepareResult Interpreter::Prepare(const std::string &query_string,
|
||||
SetupDatabaseTransaction(could_commit, unique);
|
||||
query_execution_ptr->get()->transaction_id_ = *current_db_.db_transactional_accessor_->GetTransactionId();
|
||||
}
|
||||
if (in_explicit_transaction_) {
|
||||
query_execution_ptr->get()->transaction_id_ = *current_db_.db_transactional_accessor_->GetTransactionId();
|
||||
}
|
||||
|
||||
#ifdef MG_ENTERPRISE
|
||||
if (FLAGS_coordinator && !utils::Downcast<CoordinatorQuery>(parsed_query.query) &&
|
||||
|
@ -312,6 +312,7 @@ class Interpreter final {
|
||||
|
||||
std::map<std::string, TypedValue> summary;
|
||||
std::vector<Notification> notifications;
|
||||
// Used for tracking of query and procedure memory limit
|
||||
uint64_t transaction_id_;
|
||||
|
||||
static auto Create(std::variant<utils::MonotonicBufferResource, utils::PoolResource> memory_resource,
|
||||
@ -408,10 +409,7 @@ std::map<std::string, TypedValue> Interpreter::Pull(TStream *result_stream, std:
|
||||
auto &query_execution = query_executions_[qid_value];
|
||||
|
||||
MG_ASSERT(query_execution && query_execution->prepared_query, "Query already finished executing!");
|
||||
if (query_execution->transaction_id_ != *current_transaction_) {
|
||||
std::cout << "Transaction id not same:" << query_execution->transaction_id_ << " != " << *current_transaction_
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
// Each prepared query has its own summary so we need to somehow preserve
|
||||
// it after it finishes executing because it gets destroyed alongside
|
||||
// the prepared query and its execution memory.
|
||||
@ -432,13 +430,8 @@ std::map<std::string, TypedValue> Interpreter::Pull(TStream *result_stream, std:
|
||||
// us what to do after.
|
||||
if (maybe_res) {
|
||||
if (query_execution->transaction_id_) {
|
||||
std::cout << "removing memory tracking on id: " << query_execution->transaction_id_ << std::endl;
|
||||
memgraph::memory::TryStopTrackingOnTransaction(query_execution->transaction_id_);
|
||||
}
|
||||
if (current_transaction_) {
|
||||
std::cout << "[BEFORE] removing memory tracking on id: " << *current_transaction_ << std::endl;
|
||||
// memgraph::memory::TryStopTrackingOnTransaction(query_execution->transaction_id_);
|
||||
}
|
||||
// Save its summary
|
||||
maybe_summary.emplace(std::move(query_execution->summary));
|
||||
if (!query_execution->notifications.empty()) {
|
||||
@ -453,13 +446,9 @@ std::map<std::string, TypedValue> Interpreter::Pull(TStream *result_stream, std:
|
||||
switch (*maybe_res) {
|
||||
case QueryHandlerResult::COMMIT:
|
||||
Commit();
|
||||
|
||||
break;
|
||||
case QueryHandlerResult::ABORT:
|
||||
Abort();
|
||||
// if (current_transaction_) {
|
||||
// memgraph::memory::TryStopTrackingOnTransaction(query_execution->transaction_id_);
|
||||
// }
|
||||
break;
|
||||
case QueryHandlerResult::NOTHING:
|
||||
// The only cases in which we have nothing to do are those where
|
||||
|
Loading…
Reference in New Issue
Block a user