Compare commits

...

4 Commits

Author SHA1 Message Date
antoniofilipovic
01e1c7f4d4 remove unneccessary code comment 2024-02-07 11:51:31 +01:00
antoniofilipovic
8a50abfb69 add code comment 2024-02-07 11:49:07 +01:00
antoniofilipovic
6e37b46eee fix issues on memory limit 2024-02-07 11:47:58 +01:00
antoniofilipovic
5385c741ad fix bug 2024-02-07 11:23:27 +01:00
3 changed files with 12 additions and 4 deletions

View File

@ -1,4 +1,4 @@
// Copyright 2023 Memgraph Ltd.
// Copyright 2024 Memgraph Ltd.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
@ -60,10 +60,12 @@ void *my_alloc(extent_hooks_t *extent_hooks, void *new_addr, size_t size, size_t
unsigned arena_ind) {
// This needs to be before, to throw exception in case of too big alloc
if (*commit) [[likely]] {
memgraph::utils::total_memory_tracker.Alloc(static_cast<int64_t>(size));
// This needs to happen before global alloc, because if thread tracker throws
// we will be left with incorrect state of global alloc
if (GetQueriesMemoryControl().IsThreadTracked()) [[unlikely]] {
GetQueriesMemoryControl().TrackAllocOnCurrentThread(size);
}
memgraph::utils::total_memory_tracker.Alloc(static_cast<int64_t>(size));
}
auto *ptr = old_hooks->alloc(extent_hooks, new_addr, size, alignment, zero, commit, arena_ind);

View File

@ -4172,6 +4172,10 @@ Interpreter::PrepareResult Interpreter::Prepare(const std::string &query_string,
utils::Downcast<ConstraintQuery>(parsed_query.query) != nullptr ||
upper_case_query.find(kSchemaAssert) != std::string::npos;
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

View File

@ -312,6 +312,8 @@ 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,
std::optional<PreparedQuery> prepared_query = std::nullopt) -> std::unique_ptr<QueryExecution> {
@ -427,8 +429,8 @@ std::map<std::string, TypedValue> Interpreter::Pull(TStream *result_stream, std:
// If the query finished executing, we have received a value which tells
// us what to do after.
if (maybe_res) {
if (current_transaction_) {
memgraph::memory::TryStopTrackingOnTransaction(*current_transaction_);
if (query_execution->transaction_id_) {
memgraph::memory::TryStopTrackingOnTransaction(query_execution->transaction_id_);
}
// Save its summary
maybe_summary.emplace(std::move(query_execution->summary));