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 1/3] 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(); From a8b625d861a87a29482867f0284b1fd4cb720d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Budiseli=C4=87?= Date: Fri, 19 Jan 2024 21:30:51 +0000 Subject: [PATCH 2/3] Add NuRaft ADR (#1634) Co-authored-by: Andi --- ADRs/002_nuraft.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 ADRs/002_nuraft.md diff --git a/ADRs/002_nuraft.md b/ADRs/002_nuraft.md new file mode 100644 index 000000000..9be239e17 --- /dev/null +++ b/ADRs/002_nuraft.md @@ -0,0 +1,34 @@ +# NuRaft ADR + +**Author** +Marko Budiselic (github.com/gitbuda) + +**Status** +PROPOSED + +**Date** +January 10, 2024 + +**Problem** + +In order to enhance Memgraph to have High Availability features as requested by +customers, we want to have reliable coordinators backed by RAFT consensus algorithm. Implementing +RAFT to be correct and performant is a very challenging task. Skillful Memgraph +engineers already tried 3 times and failed to deliver in a reasonable timeframe +all three times (approximately 4 person-weeks of engineering work each time). + +**Criteria** + +- easy integration with our C++ codebase +- heavily tested in production environments +- implementation of performance optimizations on top of the canonical Raft + implementation + +**Decision** + +There are a few, robust C++ implementations of Raft but as a part of other +projects or bigger libraries. **We select +[NuRaft](https://github.com/eBay/NuRaft)** because it focuses on delivering +Raft without bloatware, and it's used by +[Clickhouse](https://github.com/ClickHouse/ClickHouse) (an comparable peer to +Memgraph, a very well-established product). From 76589903a45ac2b62a6cee54189162c847e3df30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Bari=C5=A1i=C4=87?= <48765171+MarkoBarisic@users.noreply.github.com> Date: Sun, 21 Jan 2024 22:33:46 +0100 Subject: [PATCH 3/3] Update BSL license change date (#1656) --- licenses/BSL.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/licenses/BSL.txt b/licenses/BSL.txt index 9cca9dccf..c41a08af1 100644 --- a/licenses/BSL.txt +++ b/licenses/BSL.txt @@ -36,7 +36,7 @@ ADDITIONAL USE GRANT: You may use the Licensed Work in accordance with the 3. using the Licensed Work to create a work or solution which competes (or might reasonably be expected to compete) with the Licensed Work. -CHANGE DATE: 2027-08-12 +CHANGE DATE: 2028-21-01 CHANGE LICENSE: Apache License, Version 2.0 For information about alternative licensing arrangements, please visit: https://memgraph.com/legal.