From: imeevma@tarantool.org To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org Subject: [tarantool-patches] [PATCH v1 1/1] box: option to start tarantool with no format checks. Date: Mon, 13 Aug 2018 19:30:20 +0300 [thread overview] Message-ID: <a2f9f56a90c19dab406d18591dbe614c4524cdd6.1534177729.git.imeevma@gmail.com> (raw) Special option allows Tarantool create spaces with no format checks. This is useful to fix malformed formats after an upgrade from version < 1.7.5 to >= 1.7.5. Closes #3605. --- Branch: https://github.com/tarantool/tarantool/tree/imeevma/gh-3605-ignore-space-formats-option Issue: https://github.com/tarantool/tarantool/issues/3605 src/box/alter.cc | 14 ++++++- src/box/box.h | 1 + src/box/lua/cfg.cc | 13 +++++++ src/box/lua/load_cfg.lua | 3 ++ src/main.cc | 1 + test/app-tap/init_script.result | 71 ++++++++++++++++++------------------ test/box-tap/ignore_formats.test.lua | 34 +++++++++++++++++ test/box/admin.result | 2 + test/box/cfg.result | 4 ++ 9 files changed, 107 insertions(+), 36 deletions(-) create mode 100755 test/box-tap/ignore_formats.test.lua diff --git a/src/box/alter.cc b/src/box/alter.cc index ec3b91b..b379dad 100644 --- a/src/box/alter.cc +++ b/src/box/alter.cc @@ -54,6 +54,18 @@ #include "sequence.h" /** + * A flag to ignore space formats and do not validate tuples by + * them. + */ +static bool ignore_space_formats = false; + +void +box_set_ignore_space_formats(bool value) +{ + ignore_space_formats = value; +} + +/** * chap-sha1 of empty string, i.e. * base64_encode(sha1(sha1(""), 0) */ @@ -533,7 +545,7 @@ space_def_new_from_tuple(struct tuple *tuple, uint32_t errcode, const char *space_opts; struct field_def *fields; uint32_t field_count; - if (dd_version_id >= version_id(1, 7, 6)) { + if (dd_version_id >= version_id(1, 7, 6) && !ignore_space_formats) { /* Check space opts. */ space_opts = tuple_field_with_type_xc(tuple, BOX_SPACE_FIELD_OPTS, diff --git a/src/box/box.h b/src/box/box.h index 9dfb3fd..d4043db 100644 --- a/src/box/box.h +++ b/src/box/box.h @@ -176,6 +176,7 @@ void box_set_vinyl_timeout(void); void box_set_replication_timeout(void); void box_set_replication_connect_timeout(void); void box_set_replication_connect_quorum(void); +void box_set_ignore_space_formats(bool value); extern "C" { #endif /* defined(__cplusplus) */ diff --git a/src/box/lua/cfg.cc b/src/box/lua/cfg.cc index 0ca1508..c4237ba 100644 --- a/src/box/lua/cfg.cc +++ b/src/box/lua/cfg.cc @@ -177,6 +177,18 @@ lbox_cfg_set_read_only(struct lua_State *L) } static int +lbox_cfg_set_ignore_space_formats(struct lua_State *L) +{ + try { + box_set_ignore_space_formats(cfg_geti("ignore_space_"\ + "formats") != 0); + } catch (Exception *) { + luaT_error(L); + } + return 0; +} + +static int lbox_cfg_set_memtx_max_tuple_size(struct lua_State *L) { try { @@ -279,6 +291,7 @@ box_lua_cfg_init(struct lua_State *L) {"cfg_set_snap_io_rate_limit", lbox_cfg_set_snap_io_rate_limit}, {"cfg_set_checkpoint_count", lbox_cfg_set_checkpoint_count}, {"cfg_set_read_only", lbox_cfg_set_read_only}, + {"cfg_set_ignore_space_formats", lbox_cfg_set_ignore_space_formats}, {"cfg_set_memtx_max_tuple_size", lbox_cfg_set_memtx_max_tuple_size}, {"cfg_set_vinyl_max_tuple_size", lbox_cfg_set_vinyl_max_tuple_size}, {"cfg_set_vinyl_cache", lbox_cfg_set_vinyl_cache}, diff --git a/src/box/lua/load_cfg.lua b/src/box/lua/load_cfg.lua index 2a7142d..8dfcbf0 100644 --- a/src/box/lua/load_cfg.lua +++ b/src/box/lua/load_cfg.lua @@ -66,6 +66,7 @@ local default_cfg = { username = nil, coredump = false, read_only = false, + ignore_space_formats= false, hot_standby = false, checkpoint_interval = 3600, checkpoint_count = 2, @@ -124,6 +125,7 @@ local template_cfg = { checkpoint_interval = 'number', checkpoint_count = 'number', read_only = 'boolean', + ignore_space_formats= 'boolean', hot_standby = 'boolean', worker_pool_threads = 'number', replication_timeout = 'number', @@ -183,6 +185,7 @@ local dynamic_cfg = { too_long_threshold = private.cfg_set_too_long_threshold, snap_io_rate_limit = private.cfg_set_snap_io_rate_limit, read_only = private.cfg_set_read_only, + ignore_space_formats = private.cfg_set_ignore_space_formats, memtx_max_tuple_size = private.cfg_set_memtx_max_tuple_size, vinyl_max_tuple_size = private.cfg_set_vinyl_max_tuple_size, vinyl_cache = private.cfg_set_vinyl_cache, diff --git a/src/main.cc b/src/main.cc index 1682bae..30cc78d 100644 --- a/src/main.cc +++ b/src/main.cc @@ -521,6 +521,7 @@ load_cfg() title_set_custom(cfg_gets("custom_proc_title")); title_update(); + box_set_ignore_space_formats(cfg_geti("ignore_space_formats") != 0); box_cfg(); } diff --git a/test/app-tap/init_script.result b/test/app-tap/init_script.result index eea9f5b..f8b8994 100644 --- a/test/app-tap/init_script.result +++ b/test/app-tap/init_script.result @@ -9,41 +9,42 @@ box.cfg 4 coredump:false 5 force_recovery:false 6 hot_standby:false -7 listen:port -8 log:tarantool.log -9 log_format:plain -10 log_level:5 -11 log_nonblock:true -12 memtx_dir:. -13 memtx_max_tuple_size:1048576 -14 memtx_memory:107374182 -15 memtx_min_tuple_size:16 -16 pid_file:box.pid -17 read_only:false -18 readahead:16320 -19 replication_connect_timeout:30 -20 replication_sync_lag:10 -21 replication_timeout:1 -22 rows_per_wal:500000 -23 slab_alloc_factor:1.05 -24 too_long_threshold:0.5 -25 vinyl_bloom_fpr:0.05 -26 vinyl_cache:134217728 -27 vinyl_dir:. -28 vinyl_max_tuple_size:1048576 -29 vinyl_memory:134217728 -30 vinyl_page_size:8192 -31 vinyl_range_size:1073741824 -32 vinyl_read_threads:1 -33 vinyl_run_count_per_level:2 -34 vinyl_run_size_ratio:3.5 -35 vinyl_timeout:60 -36 vinyl_write_threads:2 -37 wal_dir:. -38 wal_dir_rescan_delay:2 -39 wal_max_size:268435456 -40 wal_mode:write -41 worker_pool_threads:4 +7 ignore_space_formats:false +8 listen:port +9 log:tarantool.log +10 log_format:plain +11 log_level:5 +12 log_nonblock:true +13 memtx_dir:. +14 memtx_max_tuple_size:1048576 +15 memtx_memory:107374182 +16 memtx_min_tuple_size:16 +17 pid_file:box.pid +18 read_only:false +19 readahead:16320 +20 replication_connect_timeout:30 +21 replication_sync_lag:10 +22 replication_timeout:1 +23 rows_per_wal:500000 +24 slab_alloc_factor:1.05 +25 too_long_threshold:0.5 +26 vinyl_bloom_fpr:0.05 +27 vinyl_cache:134217728 +28 vinyl_dir:. +29 vinyl_max_tuple_size:1048576 +30 vinyl_memory:134217728 +31 vinyl_page_size:8192 +32 vinyl_range_size:1073741824 +33 vinyl_read_threads:1 +34 vinyl_run_count_per_level:2 +35 vinyl_run_size_ratio:3.5 +36 vinyl_timeout:60 +37 vinyl_write_threads:2 +38 wal_dir:. +39 wal_dir_rescan_delay:2 +40 wal_max_size:268435456 +41 wal_mode:write +42 worker_pool_threads:4 -- -- Test insert from detached fiber -- diff --git a/test/box-tap/ignore_formats.test.lua b/test/box-tap/ignore_formats.test.lua new file mode 100755 index 0000000..84818ed --- /dev/null +++ b/test/box-tap/ignore_formats.test.lua @@ -0,0 +1,34 @@ +#!/usr/bin/env tarantool +-- +-- gh-3605: allow to ignore space formats via box.cfg option. +-- +local tap = require('tap') +local test = tap.test("ignore_formats") +test:plan(3) + +local format = {} +format[1] = {'field1', 'unsigned'} +format[2] = {'field2', 'unsigned'} + +-- Default value for ignore_space_formats is 'false' +box.cfg{} +local s1 = box.schema.create_space('test1', {format = format}) +local pk1 = s1:create_index('pk') +test:ok(not pcall(s1.replace, s1, {1, 'string'}), 'cannot violate format') + +-- Set ignore_space_formats = true. +box.cfg{ignore_space_formats=true} +local s2 = box.schema.create_space('test2', {format = format}) +local pk2 = s2:create_index('pk') +test:ok(pcall(s2.replace, s2, {1, 'string'}), 'can violate format') + +-- Set ignore_space_formats = false. +box.cfg{ignore_space_formats=false} +local s3 = box.schema.create_space('test3', {format = format}) +local pk3 = s3:create_index('pk') +test:ok(not pcall(s3.replace, s3, {1, 'string'}), 'cannot violate format') + +s1:drop() +s2:drop() +s3:drop() +os.exit(test:check() == true and 0 or 1) diff --git a/test/box/admin.result b/test/box/admin.result index c3e318a..9200ed8 100644 --- a/test/box/admin.result +++ b/test/box/admin.result @@ -30,6 +30,8 @@ cfg_filter(box.cfg) - false - - hot_standby - false + - - ignore_space_formats + - false - - listen - <hidden> - - log diff --git a/test/box/cfg.result b/test/box/cfg.result index cda7aa0..fad4b87 100644 --- a/test/box/cfg.result +++ b/test/box/cfg.result @@ -26,6 +26,8 @@ cfg_filter(box.cfg) - false - - hot_standby - false + - - ignore_space_formats + - false - - listen - <hidden> - - log @@ -115,6 +117,8 @@ cfg_filter(box.cfg) - false - - hot_standby - false + - - ignore_space_formats + - false - - listen - <hidden> - - log -- 2.7.4
next reply other threads:[~2018-08-13 16:30 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-08-13 16:30 imeevma [this message] 2018-09-21 17:49 imeevma
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=a2f9f56a90c19dab406d18591dbe614c4524cdd6.1534177729.git.imeevma@gmail.com \ --to=imeevma@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH v1 1/1] box: option to start tarantool with no format checks.' \ /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