[Tarantool-patches] [PATCH v3 08/13] txm: introduce tx manager
Aleksandr Lyapunov
alyapunov at tarantool.org
Wed Jul 15 16:55:31 MSK 2020
Define TX manager. It will store data for MVCC and conflict manager.
Define also 'use_mvcc_engine' in config that enables MVCC engine.
Part of #4897
---
src/box/lua/load_cfg.lua | 2 ++
src/box/txn.c | 21 +++++++++++++++++++++
src/box/txn.h | 12 ++++++++++++
src/main.cc | 5 +++++
test/app-tap/init_script.result | 1 +
test/box/admin.result | 2 ++
test/box/cfg.result | 4 ++++
7 files changed, 47 insertions(+)
diff --git a/src/box/lua/load_cfg.lua b/src/box/lua/load_cfg.lua
index 107bc15..8b40b29 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,
+ 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',
+ use_mvcc_engine = 'boolean',
worker_pool_threads = 'number',
replication_timeout = 'number',
replication_sync_lag = 'number',
diff --git a/src/box/txn.c b/src/box/txn.c
index d254edb..d647fc9 100644
--- a/src/box/txn.c
+++ b/src/box/txn.c
@@ -38,6 +38,16 @@
#include "errinj.h"
#include "iproto_constants.h"
+struct tx_manager
+{
+};
+
+/** That's a definition, see declaration for description. */
+bool tx_manager_use_mvcc_engine = false;
+
+/** The one and only instance of tx_manager. */
+static struct tx_manager txm;
+
double too_long_threshold;
/* Txn cache. */
@@ -1165,3 +1175,14 @@ txn_on_yield(struct trigger *trigger, void *event)
txn_set_flag(txn, TXN_IS_ABORTED_BY_YIELD);
return 0;
}
+
+void
+tx_manager_init()
+{
+ (void)txm;
+}
+
+void
+tx_manager_free()
+{
+}
diff --git a/src/box/txn.h b/src/box/txn.h
index 962ada0..a2374f3 100644
--- a/src/box/txn.h
+++ b/src/box/txn.h
@@ -43,6 +43,12 @@ extern "C" {
/** box statistics */
extern struct rmean *rmean_box;
+/**
+ * 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 tx_manager_use_mvcc_engine;
struct journal_entry;
struct engine;
@@ -700,6 +706,12 @@ box_txn_savepoint(void);
API_EXPORT int
box_txn_rollback_to_savepoint(box_txn_savepoint_t *savepoint);
+void
+tx_manager_init();
+
+void
+tx_manager_free();
+
#if defined(__cplusplus)
} /* extern "C" */
#endif /* defined(__cplusplus) */
diff --git a/src/main.cc b/src/main.cc
index 65b1606..07eafb8 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/txn.h"
#include "systemd.h"
#include "crypto/crypto.h"
#include "core/popen.h"
@@ -569,6 +570,8 @@ load_cfg(void)
log_format,
background);
+ tx_manager_use_mvcc_engine = cfg_getb("use_mvcc_engine");
+
if (background)
daemonize();
@@ -667,6 +670,7 @@ tarantool_free(void)
random_free();
#endif
crypto_free();
+ 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();
+ 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..3838e35 100644
--- a/test/app-tap/init_script.result
+++ b/test/app-tap/init_script.result
@@ -37,6 +37,7 @@ slab_alloc_factor:1.05
sql_cache_size:5242880
strip_core:true
too_long_threshold:0.5
+use_mvcc_engine:false
vinyl_bloom_fpr:0.05
vinyl_cache:134217728
vinyl_dir:.
diff --git a/test/box/admin.result b/test/box/admin.result
index ab3e80a..278e8c5 100644
--- a/test/box/admin.result
+++ b/test/box/admin.result
@@ -95,6 +95,8 @@ cfg_filter(box.cfg)
- true
- - too_long_threshold
- 0.5
+ - - use_mvcc_engine
+ - false
- - vinyl_bloom_fpr
- 0.05
- - vinyl_cache
diff --git a/test/box/cfg.result b/test/box/cfg.result
index bdd210b..b5ba165 100644
--- a/test/box/cfg.result
+++ b/test/box/cfg.result
@@ -83,6 +83,8 @@ cfg_filter(box.cfg)
| - true
| - - too_long_threshold
| - 0.5
+ | - - use_mvcc_engine
+ | - false
| - - vinyl_bloom_fpr
| - 0.05
| - - vinyl_cache
@@ -190,6 +192,8 @@ cfg_filter(box.cfg)
| - true
| - - too_long_threshold
| - 0.5
+ | - - use_mvcc_engine
+ | - false
| - - vinyl_bloom_fpr
| - 0.05
| - - vinyl_cache
--
2.7.4
More information about the Tarantool-patches
mailing list