Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Kirill Shcherbatov <kshcherbatov@tarantool.org>,
	tarantool-patches@freelists.org,
	Kirill Yukhin <kyukhin@tarantool.org>
Cc: "n.pettik" <korablev@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v2 3/9] box: fix Tarantool upgrade from 2.1.0 to 2.1.1
Date: Fri, 22 Mar 2019 13:21:10 +0300	[thread overview]
Message-ID: <1046a6c0-c719-05cf-2c46-b5d5331c3d00@tarantool.org> (raw)
In-Reply-To: <acc743f1-595d-a95d-d860-7ab34396bf45@tarantool.org>

LGTM.

On 22/03/2019 13:18, Kirill Shcherbatov wrote:
> On 22.03.2019 12:28, Vladislav Shpilevoy wrote:
>> Hi! Thanks for the patch!
> Hi! Thank you for review and fixes.
>> 1. Why 'priv'? upgrade_priv_to_2_1_0 contains 'priv' suffix,
>> because it upgrades _priv system space and privileges.
> Ok, just move this code block down.
> 
>> 2. Looks like a debug print, that you've forgotten to drop.
>> Please, do it.
> Yep. Dropped.
> 
>> 3. As I understand, legacy means that whatever is stored here, it
>> should be skipped. But it contradicts with other member of struct
>> opt_def - your legacy structure contains a type in enum opt_type type.
>> Moreover - invalid type.
> Already fixed on branch.
> 
> ===================================================
> 
> Tarantool could not start from the snapshot created by version
> 2.1.0 because the new version 2.1.1 does not support the
> index.opts.sql index opt and stops the execution.
> Introduced a special state OPT_DEF_LEGACY macro to ignore legacy
> options and introduced migration code in upgrade.lua.
> ---
>   src/box/bootstrap.snap                        | Bin 1831 -> 1830 bytes
>   src/box/index_def.c                           |   1 +
>   src/box/lua/upgrade.lua                       |  19 ++++++-
>   src/box/opt_def.c                             |   4 ++
>   src/box/opt_def.h                             |   4 ++
>   test/box-py/bootstrap.result                  |   2 +-
>   test/sql/upgrade.result                       |  49 ++++++++++++++++++
>   test/sql/upgrade.test.lua                     |  18 +++++++
>   .../upgrade/2.1.0/00000000000000000003.snap   | Bin 0 -> 2124 bytes
>   9 files changed, 95 insertions(+), 2 deletions(-)
>   create mode 100644 test/sql/upgrade/2.1.0/00000000000000000003.snap
> 
> diff --git a/src/box/bootstrap.snap b/src/box/bootstrap.snap
> index 0bb446fb6903ac3ef630c419b909f7db3df0372a..ae7b488633edd4a422f8a1fb60738f2cf5ff8ce5 100644
> GIT binary patch
> 
> diff --git a/src/box/index_def.c b/src/box/index_def.c
> index 6c37f9f1d..c743d12ce 100644
> --- a/src/box/index_def.c
> +++ b/src/box/index_def.c
> @@ -62,6 +62,7 @@ const struct opt_def index_opts_reg[] = {
>   	OPT_DEF("run_size_ratio", OPT_FLOAT, struct index_opts, run_size_ratio),
>   	OPT_DEF("bloom_fpr", OPT_FLOAT, struct index_opts, bloom_fpr),
>   	OPT_DEF("lsn", OPT_INT64, struct index_opts, lsn),
> +	OPT_DEF_LEGACY("sql"),
>   	OPT_END,
>   };
>   
> diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua
> index c72711ff7..dc7328714 100644
> --- a/src/box/lua/upgrade.lua
> +++ b/src/box/lua/upgrade.lua
> @@ -616,6 +616,22 @@ local function upgrade_to_2_1_0()
>       upgrade_priv_to_2_1_0()
>   end
>   
> +--------------------------------------------------------------------------------
> +-- Tarantool 2.1.1
> +--------------------------------------------------------------------------------
> +
> +local function upgrade_to_2_1_1()
> +    local _index = box.space[box.schema.INDEX_ID]
> +    for _, index in _index:pairs() do
> +        local opts = index.opts
> +        if opts['sql'] ~= nil then
> +            opts['sql'] = nil
> +            _index:replace(box.tuple.new({index.id, index.iid, index.name,
> +                                        index.type, opts, index.parts}))
> +        end
> +    end
> +end
> +
>   local function get_version()
>       local version = box.space._schema:get{'version'}
>       if version == nil then
> @@ -643,7 +659,8 @@ local function upgrade(options)
>           {version = mkversion(1, 7, 7), func = upgrade_to_1_7_7, auto = true},
>           {version = mkversion(1, 10, 0), func = upgrade_to_1_10_0, auto = true},
>           {version = mkversion(1, 10, 2), func = upgrade_to_1_10_2, auto = true},
> -        {version = mkversion(2, 1, 0), func = upgrade_to_2_1_0, auto = true}
> +        {version = mkversion(2, 1, 0), func = upgrade_to_2_1_0, auto = true},
> +        {version = mkversion(2, 1, 1), func = upgrade_to_2_1_1, auto = true}
>       }
>   
>       for _, handler in ipairs(handlers) do
> diff --git a/src/box/opt_def.c b/src/box/opt_def.c
> index 1d1f09ed5..c78021440 100644
> --- a/src/box/opt_def.c
> +++ b/src/box/opt_def.c
> @@ -45,6 +45,7 @@ const char *opt_type_strs[] = {
>   	/* [OPT_STRPTR] = */ "string",
>   	/* [OPT_ENUM]   = */ "enum",
>   	/* [OPT_ARRAY]  = */ "array",
> +	/* [OPT_LEGACY] = */ "legacy",
>   };
>   
>   static int
> @@ -145,6 +146,9 @@ opt_set(void *opts, const struct opt_def *def, const char **val,
>   		if (def->to_array(val, ival, opt, errcode, field_no) != 0)
>   			return -1;
>   		break;
> +	case OPT_LEGACY:
> +		mp_next(val);
> +		break;
>   	default:
>   		unreachable();
>   	}
> diff --git a/src/box/opt_def.h b/src/box/opt_def.h
> index 318204e91..21544412c 100644
> --- a/src/box/opt_def.h
> +++ b/src/box/opt_def.h
> @@ -48,6 +48,7 @@ enum opt_type {
>   	OPT_STRPTR,	/* char*  */
>   	OPT_ENUM,	/* enum */
>   	OPT_ARRAY,	/* array */
> +	OPT_LEGACY,	/* any type, skipped */
>   	opt_type_MAX,
>   };
>   
> @@ -106,6 +107,9 @@ struct opt_def {
>   	 { key, OPT_ARRAY, offsetof(opts, field), sizeof(((opts *)0)->field), \
>   	   NULL, 0, NULL, 0, {(void *)to_array} }
>   
> +#define OPT_DEF_LEGACY(key) \
> +	{ key, OPT_LEGACY, 0, 0, NULL, 0, NULL, 0, {NULL} }
> +
>   #define OPT_END {NULL, opt_type_MAX, 0, 0, NULL, 0, NULL, 0, {NULL}}
>   
>   struct region;
> diff --git a/test/box-py/bootstrap.result b/test/box-py/bootstrap.result
> index 3e4394557..cdf07117e 100644
> --- a/test/box-py/bootstrap.result
> +++ b/test/box-py/bootstrap.result
> @@ -4,7 +4,7 @@ box.internal.bootstrap()
>   box.space._schema:select{}
>   ---
>   - - ['max_id', 511]
> -  - ['version', 2, 1, 0]
> +  - ['version', 2, 1, 1]
>   ...
>   box.space._cluster:select{}
>   ---
> diff --git a/test/sql/upgrade.result b/test/sql/upgrade.result
> index 02ab9b42b..fb1682ace 100644
> --- a/test/sql/upgrade.result
> +++ b/test/sql/upgrade.result
> @@ -158,3 +158,52 @@ test_run:cmd('cleanup server upgrade')
>   ---
>   - true
>   ...
> +-- Test Tarantool 2.1.0 to 2.1.1 migration.
> +work_dir = 'sql/upgrade/2.1.0/'
> +---
> +...
> +test_run:cmd('create server upgrade210 with script="sql/upgrade/upgrade.lua", workdir="' .. work_dir .. '"')
> +---
> +- true
> +...
> +test_run:cmd('start server upgrade210')
> +---
> +- true
> +...
> +test_run:switch('upgrade210')
> +---
> +- true
> +...
> +s = box.space.T2
> +---
> +...
> +s ~= nil
> +---
> +- true
> +...
> +i = box.space._index:select(s.id)
> +---
> +...
> +i ~= nil
> +---
> +- true
> +...
> +i[1].opts.sql == nil
> +---
> +- true
> +...
> +s:drop()
> +---
> +...
> +test_run:switch('default')
> +---
> +- true
> +...
> +test_run:cmd('stop server upgrade210')
> +---
> +- true
> +...
> +test_run:cmd('cleanup server upgrade210')
> +---
> +- true
> +...
> diff --git a/test/sql/upgrade.test.lua b/test/sql/upgrade.test.lua
> index cd4dd3cca..581833b9e 100644
> --- a/test/sql/upgrade.test.lua
> +++ b/test/sql/upgrade.test.lua
> @@ -53,3 +53,21 @@ box.sql.execute("DROP TABLE T_OUT;")
>   test_run:switch('default')
>   test_run:cmd('stop server upgrade')
>   test_run:cmd('cleanup server upgrade')
> +
> +-- Test Tarantool 2.1.0 to 2.1.1 migration.
> +work_dir = 'sql/upgrade/2.1.0/'
> +test_run:cmd('create server upgrade210 with script="sql/upgrade/upgrade.lua", workdir="' .. work_dir .. '"')
> +test_run:cmd('start server upgrade210')
> +
> +test_run:switch('upgrade210')
> +
> +s = box.space.T2
> +s ~= nil
> +i = box.space._index:select(s.id)
> +i ~= nil
> +i[1].opts.sql == nil
> +s:drop()
> +
> +test_run:switch('default')
> +test_run:cmd('stop server upgrade210')
> +test_run:cmd('cleanup server upgrade210')
> diff --git a/test/sql/upgrade/2.1.0/00000000000000000003.snap b/test/sql/upgrade/2.1.0/00000000000000000003.snap
> new file mode 100644
> index 0000000000000000000000000000000000000000..25bb78734dd5680c510bdb36cf94776f19c4b0c2
> 
> -- 
> 2.21.0
> 

  reply	other threads:[~2019-03-22 10:21 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30  8:59 [tarantool-patches] [PATCH v2 0/9] sql: Checks on server side Kirill Shcherbatov
2019-01-30  8:59 ` [tarantool-patches] [PATCH v2 1/9] box: fix upgrade script for _fk_constraint space Kirill Shcherbatov
2019-03-11 18:44   ` [tarantool-patches] " n.pettik
2019-03-13 11:36   ` Kirill Yukhin
2019-01-30  8:59 ` [tarantool-patches] [PATCH v2 2/9] box: fix _trigger and _ck_constraint access check Kirill Shcherbatov
2019-03-11 19:29   ` [tarantool-patches] " n.pettik
2019-03-22  9:29     ` Vladislav Shpilevoy
2019-03-26 10:59     ` Kirill Shcherbatov
2019-04-01 14:06       ` n.pettik
2019-03-13 11:38   ` Kirill Yukhin
2019-03-13 11:44     ` Kirill Yukhin
2019-01-30  8:59 ` [tarantool-patches] [PATCH v2 3/9] box: fix Tarantool upgrade from 2.1.0 to 2.1.1 Kirill Shcherbatov
2019-03-12 11:45   ` [tarantool-patches] " n.pettik
2019-03-20 15:12     ` n.pettik
2019-03-20 15:38       ` Kirill Shcherbatov
2019-03-21 15:23         ` n.pettik
2019-03-21 15:36           ` Vladislav Shpilevoy
2019-03-22  9:28         ` Vladislav Shpilevoy
2019-03-22 10:18           ` Kirill Shcherbatov
2019-03-22 10:21             ` Vladislav Shpilevoy [this message]
2019-03-26  9:52   ` Kirill Yukhin
2019-01-30  8:59 ` [tarantool-patches] [PATCH v2 4/9] box: fix on_replace_trigger_rollback routine Kirill Shcherbatov
2019-03-11 20:00   ` [tarantool-patches] " n.pettik
2019-03-13 11:39   ` Kirill Yukhin
2019-01-30  8:59 ` [tarantool-patches] [PATCH v2 5/9] schema: add new system space for CHECK constraints Kirill Shcherbatov
2019-03-22  9:29   ` [tarantool-patches] " Vladislav Shpilevoy
2019-03-22  9:52     ` n.pettik
2019-03-26 10:59     ` Kirill Shcherbatov
2019-04-01 19:45       ` n.pettik
2019-04-16 13:51         ` Kirill Shcherbatov
2019-01-30  8:59 ` [tarantool-patches] [PATCH v2 6/9] sql: disallow use of TYPEOF in Check Kirill Shcherbatov
2019-03-26 10:59   ` [tarantool-patches] " Kirill Shcherbatov
2019-04-01 19:52     ` n.pettik
2019-01-30  8:59 ` [tarantool-patches] [PATCH v2 7/9] sql: refactor sqlite3_reset routine Kirill Shcherbatov
2019-03-26 10:59   ` [tarantool-patches] " Kirill Shcherbatov
2019-01-30  8:59 ` [tarantool-patches] [PATCH v2 8/9] box: exported sql_bind structure and API Kirill Shcherbatov
2019-03-26 10:59   ` [tarantool-patches] " Kirill Shcherbatov
2019-01-30  8:59 ` [tarantool-patches] [PATCH v2 9/9] sql: run check constraint tests on space alter Kirill Shcherbatov
2019-03-26 10:59   ` [tarantool-patches] " Kirill Shcherbatov
2019-04-02 14:14     ` n.pettik
2019-04-16 13:51       ` Kirill Shcherbatov

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=1046a6c0-c719-05cf-2c46-b5d5331c3d00@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=kyukhin@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v2 3/9] box: fix Tarantool upgrade from 2.1.0 to 2.1.1' \
    /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