From 9c89fce249a6be66555cea1f9a9b0855639a4668 Mon Sep 17 00:00:00 2001 From: andrejtonev <29177572+andrejtonev@users.noreply.github.com> Date: Fri, 19 Jan 2024 18:05:47 +0100 Subject: [PATCH] Bugfix: Shutdown blocks due to wrong execution order (#1649) * Bugfix: Destorying settings before stopping license checker * Bugfix: Python GC running while shutting down --- src/license/license.cpp | 4 ++-- src/license/license.hpp | 4 +++- src/memgraph.cpp | 5 ++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/license/license.cpp b/src/license/license.cpp index ff5306dab..653e66222 100644 --- a/src/license/license.cpp +++ b/src/license/license.cpp @@ -1,4 +1,4 @@ -// Copyright 2022 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 @@ -92,7 +92,7 @@ void RegisterLicenseSettings(LicenseChecker &license_checker, utils::Settings &s // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) LicenseChecker global_license_checker; -LicenseChecker::~LicenseChecker() { scheduler_.Stop(); } +LicenseChecker::~LicenseChecker() { Finalize(); } std::pair LicenseChecker::ExtractLicenseInfo(const utils::Settings &settings) const { if (license_info_override_) { diff --git a/src/license/license.hpp b/src/license/license.hpp index da47ae0ff..b2e7dcce4 100644 --- a/src/license/license.hpp +++ b/src/license/license.hpp @@ -1,4 +1,4 @@ -// Copyright 2022 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 @@ -89,6 +89,8 @@ struct LicenseChecker { utils::Synchronized, utils::SpinLock> &GetLicenseInfo(); + void Finalize() { scheduler_.Stop(); } + private: std::pair ExtractLicenseInfo(const utils::Settings &settings) const; void RevalidateLicense(const utils::Settings &settings); diff --git a/src/memgraph.cpp b/src/memgraph.cpp index e6c8dd1cd..cf954560d 100644 --- a/src/memgraph.cpp +++ b/src/memgraph.cpp @@ -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 @@ -257,6 +257,8 @@ int main(int argc, char **argv) { // register all runtime settings memgraph::license::RegisterLicenseSettings(memgraph::license::global_license_checker, memgraph::utils::global_settings); + memgraph::utils::OnScopeExit global_license_finalizer([] { memgraph::license::global_license_checker.Finalize(); }); + memgraph::flags::run_time::Initialize(); memgraph::license::global_license_checker.CheckEnvLicense(); @@ -546,6 +548,7 @@ int main(int argc, char **argv) { memgraph::query::procedure::gModuleRegistry.UnloadAllModules(); + python_gc_scheduler.Stop(); Py_END_ALLOW_THREADS; // Shutdown Python Py_Finalize();