From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 4F852469719 for ; Tue, 8 Sep 2020 13:22:15 +0300 (MSK) Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1kFalS-0006tc-Rw for tarantool-patches@dev.tarantool.org; Tue, 08 Sep 2020 13:22:15 +0300 From: Aleksandr Lyapunov Date: Tue, 8 Sep 2020 13:22:05 +0300 Message-Id: <1599560532-27089-6-git-send-email-alyapunov@tarantool.org> In-Reply-To: <1599560532-27089-1-git-send-email-alyapunov@tarantool.org> References: <1599560532-27089-1-git-send-email-alyapunov@tarantool.org> Subject: [Tarantool-patches] [PATCH v4 05/12] txm: introduce memtx tx manager List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org Define memtx TX manager. It will store data for MVCC and conflict manager. Define also 'memtx_use_mvcc_engine' in config that enables that MVCC engine. Part of #4897 --- src/box/CMakeLists.txt | 1 + src/box/lua/load_cfg.lua | 2 ++ src/box/memtx_tx.c | 52 +++++++++++++++++++++++++++++++++++ src/box/memtx_tx.h | 61 +++++++++++++++++++++++++++++++++++++++++ src/main.cc | 5 ++++ test/app-tap/init_script.result | 1 + test/box/admin.result | 2 ++ test/box/cfg.result | 4 +++ 8 files changed, 128 insertions(+) create mode 100644 src/box/memtx_tx.c create mode 100644 src/box/memtx_tx.h diff --git a/src/box/CMakeLists.txt b/src/box/CMakeLists.txt index b8b2689..2ed7270 100644 --- a/src/box/CMakeLists.txt +++ b/src/box/CMakeLists.txt @@ -128,6 +128,7 @@ add_library(box STATIC memtx_tree.c memtx_rtree.c memtx_bitset.c + memtx_tx.c engine.c memtx_engine.c memtx_space.c diff --git a/src/box/lua/load_cfg.lua b/src/box/lua/load_cfg.lua index 53f5728..92347a9 100644 --- a/src/box/lua/load_cfg.lua +++ b/src/box/lua/load_cfg.lua @@ -82,6 +82,7 @@ local default_cfg = { coredump = false, read_only = false, hot_standby = false, + memtx_use_mvcc_engine = false, checkpoint_interval = 3600, checkpoint_wal_threshold = 1e18, checkpoint_count = 2, @@ -162,6 +163,7 @@ local template_cfg = { checkpoint_count = 'number', read_only = 'boolean', hot_standby = 'boolean', + memtx_use_mvcc_engine = 'boolean', worker_pool_threads = 'number', replication_timeout = 'number', replication_sync_lag = 'number', diff --git a/src/box/memtx_tx.c b/src/box/memtx_tx.c new file mode 100644 index 0000000..479aa48 --- /dev/null +++ b/src/box/memtx_tx.c @@ -0,0 +1,52 @@ +/* + * Copyright 2010-2020, Tarantool AUTHORS, please see AUTHORS file. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#include "memtx_tx.h" + +struct tx_manager +{ +}; + +/** That's a definition, see declaration for description. */ +bool memtx_tx_manager_use_mvcc_engine = false; + +/** The one and only instance of tx_manager. */ +static struct tx_manager txm; + +void +memtx_tx_manager_init() +{ + (void)txm; +} + +void +memtx_tx_manager_free() +{ +} diff --git a/src/box/memtx_tx.h b/src/box/memtx_tx.h new file mode 100644 index 0000000..fb2cb4d --- /dev/null +++ b/src/box/memtx_tx.h @@ -0,0 +1,61 @@ +#pragma once +/* + * Copyright 2010-2020, Tarantool AUTHORS, please see AUTHORS file. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +#if defined(__cplusplus) +extern "C" { +#endif /* defined(__cplusplus) */ + +/** + * Global flag that enables mvcc engine. + * If set, memtx starts to apply statements through txm history mechanism + * and tx manager itself transaction reads in order to detect conflicts. + */ +extern bool memtx_tx_manager_use_mvcc_engine; + +/** + * Initialize memtx transaction manager. + */ +void +memtx_tx_manager_init(); + +/** + * Free resources of memtx transaction manager. + */ +void +memtx_tx_manager_free(); + + +#if defined(__cplusplus) +} /* extern "C" */ +#endif /* defined(__cplusplus) */ diff --git a/src/main.cc b/src/main.cc index 65b1606..2f48f47 100644 --- a/src/main.cc +++ b/src/main.cc @@ -75,6 +75,7 @@ #include #include "box/lua/init.h" /* box_lua_init() */ #include "box/session.h" +#include "box/memtx_tx.h" #include "systemd.h" #include "crypto/crypto.h" #include "core/popen.h" @@ -569,6 +570,8 @@ load_cfg(void) log_format, background); + memtx_tx_manager_use_mvcc_engine = cfg_getb("memtx_use_mvcc_engine"); + if (background) daemonize(); @@ -667,6 +670,7 @@ tarantool_free(void) random_free(); #endif crypto_free(); + memtx_tx_manager_free(); coll_free(); systemd_free(); say_logger_free(); @@ -830,6 +834,7 @@ main(int argc, char **argv) signal_init(); cbus_init(); coll_init(); + memtx_tx_manager_init(); crypto_init(); systemd_init(); tarantool_lua_init(tarantool_bin, main_argc, main_argv); diff --git a/test/app-tap/init_script.result b/test/app-tap/init_script.result index 857f0c9..c8974d7 100644 --- a/test/app-tap/init_script.result +++ b/test/app-tap/init_script.result @@ -21,6 +21,7 @@ memtx_dir:. memtx_max_tuple_size:1048576 memtx_memory:107374182 memtx_min_tuple_size:16 +memtx_use_mvcc_engine:false net_msg_max:768 pid_file:box.pid read_only:false diff --git a/test/box/admin.result b/test/box/admin.result index ab3e80a..d1540a7 100644 --- a/test/box/admin.result +++ b/test/box/admin.result @@ -63,6 +63,8 @@ cfg_filter(box.cfg) - 107374182 - - memtx_min_tuple_size - + - - memtx_use_mvcc_engine + - false - - net_msg_max - 768 - - pid_file diff --git a/test/box/cfg.result b/test/box/cfg.result index bdd210b..fcfc64b 100644 --- a/test/box/cfg.result +++ b/test/box/cfg.result @@ -51,6 +51,8 @@ cfg_filter(box.cfg) | - 107374182 | - - memtx_min_tuple_size | - + | - - memtx_use_mvcc_engine + | - false | - - net_msg_max | - 768 | - - pid_file @@ -158,6 +160,8 @@ cfg_filter(box.cfg) | - 107374182 | - - memtx_min_tuple_size | - + | - - memtx_use_mvcc_engine + | - false | - - net_msg_max | - 768 | - - pid_file -- 2.7.4