From: Aleksandr Lyapunov <alyapunov@tarantool.org> To: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH v4 05/12] txm: introduce memtx tx manager Date: Tue, 8 Sep 2020 13:22:05 +0300 [thread overview] Message-ID: <1599560532-27089-6-git-send-email-alyapunov@tarantool.org> (raw) In-Reply-To: <1599560532-27089-1-git-send-email-alyapunov@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 <COPYRIGHT HOLDER> ``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 + * <COPYRIGHT HOLDER> 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 <COPYRIGHT HOLDER> ``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 + * <COPYRIGHT HOLDER> 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 <stdbool.h> + +#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 <libutil.h> #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 - <hidden> + - - 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 | - <hidden> + | - - memtx_use_mvcc_engine + | - false | - - net_msg_max | - 768 | - - pid_file @@ -158,6 +160,8 @@ cfg_filter(box.cfg) | - 107374182 | - - memtx_min_tuple_size | - <hidden> + | - - memtx_use_mvcc_engine + | - false | - - net_msg_max | - 768 | - - pid_file -- 2.7.4
next prev parent reply other threads:[~2020-09-08 10:22 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-09-08 10:22 [Tarantool-patches] [PATCH v4 00/12] Transaction engine for memtx engine Aleksandr Lyapunov 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 01/12] vinyl: rename tx_manager -> vy_tx_manager Aleksandr Lyapunov 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 02/12] txm: add TX status Aleksandr Lyapunov 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 03/12] txm: save does_require_old_tuple flag in txn_stmt Aleksandr Lyapunov 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 04/12] txm: introduce prepare sequence number Aleksandr Lyapunov 2020-09-08 10:22 ` Aleksandr Lyapunov [this message] 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 06/12] txm: introduce conflict tracker Aleksandr Lyapunov 2020-09-14 16:36 ` Nikita Pettik 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 07/12] txm: introduce memtx_story Aleksandr Lyapunov 2020-09-15 14:33 ` Nikita Pettik 2020-09-22 17:51 ` Aleksandr Lyapunov 2020-09-23 10:25 ` Nikita Pettik 2020-09-23 11:09 ` Aleksandr Lyapunov 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 08/12] txm: introduce snapshot cleaner Aleksandr Lyapunov 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 09/12] txm: clarify all fetched tuples Aleksandr Lyapunov 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 10/12] txm: use new tx manager in memtx Aleksandr Lyapunov 2020-09-15 17:59 ` Nikita Pettik 2020-09-22 17:53 ` Aleksandr Lyapunov 2020-09-23 10:26 ` Nikita Pettik 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 11/12] test: move txn_proxy.lua to box/lua Aleksandr Lyapunov 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 12/12] txm: add a test Aleksandr Lyapunov 2020-09-15 18:05 ` Nikita Pettik 2020-09-22 17:58 ` Aleksandr Lyapunov 2020-09-23 11:07 ` Nikita Pettik 2020-09-23 11:12 ` Aleksandr Lyapunov 2020-09-23 12:18 ` [Tarantool-patches] [PATCH v4 00/12] Transaction engine for memtx engine Kirill Yukhin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1599560532-27089-6-git-send-email-alyapunov@tarantool.org \ --to=alyapunov@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v4 05/12] txm: introduce memtx tx manager' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox