Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH 0/3] Fix upgrade from 2.1 sequence
@ 2020-02-17 20:57 Vladislav Shpilevoy
  2020-02-17 20:57 ` [Tarantool-patches] [PATCH 1/3] upgrade: add missing sys triggers off and erasure Vladislav Shpilevoy
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Vladislav Shpilevoy @ 2020-02-17 20:57 UTC (permalink / raw)
  To: tarantool-patches, alexander.turenko, korablev

The patchset fixes inability to upgrade from 2.1 if there is an
automatically generated sequence. The problem was that upgrade
tried to update a tuple in _space_sequence in-place, calling
space:update() method. But it was not properly supported for
_space_sequence. The patchset turns it into delete + insert, and
bans updates for this space.

Branch: http://github.com/tarantool/tarantool/tree/gerold103/gh-4771-2.2-upgrade
Issue: https://github.com/tarantool/tarantool/issues/4771

@ChangeLog
- Fixed inability to upgrade from 2.1, if there was an
  automatically generated sequence (gh-4771).

Vladislav Shpilevoy (3):
  upgrade: add missing sys triggers off and erasure
  box: forbid to update/replace _space_sequence
  upgrade: fix generated sequence upgrade from 2.1

 src/box/alter.cc                              |   8 +-
 src/box/lua/upgrade.lua                       |  47 ++--
 test/box/sequence.result                      |  19 ++
 test/box/sequence.test.lua                    |   9 +
 test/xlog/gh-4771-upgrade.result              |  78 ++++++
 test/xlog/gh-4771-upgrade.test.lua            |  24 ++
 test/xlog/suite.cfg                           |   5 -
 test/xlog/suite.ini                           |   3 +-
 test/xlog/upgrade.result                      | 265 ------------------
 test/xlog/upgrade.test.lua                    |  46 ---
 .../00000000000000000014.snap                 | Bin 0 -> 4622 bytes
 .../2.1.3/gh-4771-upgrade-sequence/fill.lua   |  14 +
 12 files changed, 172 insertions(+), 346 deletions(-)
 create mode 100644 test/xlog/gh-4771-upgrade.result
 create mode 100644 test/xlog/gh-4771-upgrade.test.lua
 delete mode 100644 test/xlog/suite.cfg
 delete mode 100644 test/xlog/upgrade.result
 delete mode 100644 test/xlog/upgrade.test.lua
 create mode 100644 test/xlog/upgrade/2.1.3/gh-4771-upgrade-sequence/00000000000000000014.snap
 create mode 100644 test/xlog/upgrade/2.1.3/gh-4771-upgrade-sequence/fill.lua

-- 
2.21.1 (Apple Git-122.3)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Tarantool-patches] [PATCH 1/3] upgrade: add missing sys triggers off and erasure
  2020-02-17 20:57 [Tarantool-patches] [PATCH 0/3] Fix upgrade from 2.1 sequence Vladislav Shpilevoy
@ 2020-02-17 20:57 ` Vladislav Shpilevoy
  2020-02-21 15:20   ` Nikita Pettik
  2020-02-17 20:57 ` [Tarantool-patches] [PATCH 2/3] box: forbid to update/replace _space_sequence Vladislav Shpilevoy
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Vladislav Shpilevoy @ 2020-02-17 20:57 UTC (permalink / raw)
  To: tarantool-patches, alexander.turenko, korablev

box.internal.bootstrap() before doing anything turns off system
space triggers, because it is likely to do some hard changes
violating existing rules. And eliminates data from all system
spaces to fill it from the scratch.

Each time when a new space is added, its erasure and turning off
its triggers should have been called explicitly here. As a result
it was not done sometimes, by accident. For example, triggers
were not turned off for _sequence_data, _sequence,
_space_sequence.

Content removal wasn't done for _space_sequence.

The patch makes a generic solution which does not require manual
patching of trigger manipulation and truncation anymore.

The bug was discovered while working on #4771, although it is not
related.
---
 src/box/lua/upgrade.lua | 40 +++++++++++++++-------------------------
 1 file changed, 15 insertions(+), 25 deletions(-)

diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua
index c69b6b543..bd28c1001 100644
--- a/src/box/lua/upgrade.lua
+++ b/src/box/lua/upgrade.lua
@@ -63,18 +63,21 @@ local function truncate(space)
     end
 end
 
+local function foreach_system_space(cb)
+    local max = box.schema.SYSTEM_ID_MAX
+    for id, space in pairs(box.space) do
+        if type(id) == 'number' and
+           (space.engine == 'memtx' or space.engine == 'vinyl') then
+            if id > max then
+                break
+            end
+            cb(space)
+        end
+    end
+end
+
 local function set_system_triggers(val)
-    box.space._space:run_triggers(val)
-    box.space._index:run_triggers(val)
-    box.space._user:run_triggers(val)
-    box.space._func:run_triggers(val)
-    box.space._priv:run_triggers(val)
-    box.space._trigger:run_triggers(val)
-    box.space._collation:run_triggers(val)
-    box.space._schema:run_triggers(val)
-    box.space._cluster:run_triggers(val)
-    box.space._fk_constraint:run_triggers(val)
-    box.space._ck_constraint:run_triggers(val)
+    foreach_system_space(function(s) s:run_triggers(val) end)
 end
 
 --------------------------------------------------------------------------------
@@ -82,20 +85,7 @@ end
 --------------------------------------------------------------------------------
 
 local function erase()
-    truncate(box.space._space)
-    truncate(box.space._index)
-    truncate(box.space._user)
-    truncate(box.space._func)
-    truncate(box.space._priv)
-    truncate(box.space._sequence_data)
-    truncate(box.space._sequence)
-    truncate(box.space._truncate)
-    truncate(box.space._collation)
-    truncate(box.space._trigger)
-    truncate(box.space._schema)
-    truncate(box.space._cluster)
-    truncate(box.space._fk_constraint)
-    truncate(box.space._ck_constraint)
+    foreach_system_space(function(s) truncate(s) end)
 end
 
 local function create_sysview(source_id, target_id)
-- 
2.21.1 (Apple Git-122.3)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Tarantool-patches] [PATCH 2/3] box: forbid to update/replace _space_sequence
  2020-02-17 20:57 [Tarantool-patches] [PATCH 0/3] Fix upgrade from 2.1 sequence Vladislav Shpilevoy
  2020-02-17 20:57 ` [Tarantool-patches] [PATCH 1/3] upgrade: add missing sys triggers off and erasure Vladislav Shpilevoy
@ 2020-02-17 20:57 ` Vladislav Shpilevoy
  2020-02-21 15:29   ` Nikita Pettik
  2020-02-17 20:57 ` [Tarantool-patches] [PATCH 3/3] upgrade: fix generated sequence upgrade from 2.1 Vladislav Shpilevoy
  2020-02-24 19:48 ` [Tarantool-patches] [PATCH 0/3] Fix upgrade from 2.1 sequence Kirill Yukhin
  3 siblings, 1 reply; 11+ messages in thread
From: Vladislav Shpilevoy @ 2020-02-17 20:57 UTC (permalink / raw)
  To: tarantool-patches, alexander.turenko, korablev

Anyway this does not work for generated sequences. A proper
support of update would complicate the code and won't give
anything useful.

Part of #4771
---
 src/box/alter.cc           |  8 ++++++--
 test/box/sequence.result   | 19 +++++++++++++++++++
 test/box/sequence.test.lua |  9 +++++++++
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/src/box/alter.cc b/src/box/alter.cc
index 64af71c61..50121c79c 100644
--- a/src/box/alter.cc
+++ b/src/box/alter.cc
@@ -4713,9 +4713,13 @@ on_replace_dd_space_sequence(struct trigger * /* trigger */, void *event)
 		return -1;
 	}
 
+	if ((stmt->new_tuple != NULL) == (stmt->old_tuple != NULL)) {
+		diag_set(ClientError, ER_UNSUPPORTED,
+			 "space \"_space_sequence\"", "update");
+		return -1;
+	}
+
 	enum priv_type priv_type = stmt->new_tuple ? PRIV_C : PRIV_D;
-	if (stmt->new_tuple && stmt->old_tuple)
-		priv_type = PRIV_A;
 
 	/* Check we have the correct access type on the sequence.  * */
 	if (is_generated || !stmt->new_tuple) {
diff --git a/test/box/sequence.result b/test/box/sequence.result
index 917952909..0a6cfee2c 100644
--- a/test/box/sequence.result
+++ b/test/box/sequence.result
@@ -2270,3 +2270,22 @@ sq:next() -- 2
 sq:drop()
 ---
 ...
+--
+-- Update on _space_sequence is forbidden.
+--
+s = box.schema.create_space('test')
+---
+...
+pk = s:create_index('pk', {sequence = true})
+---
+...
+t = box.space._space_sequence:get({s.id})
+---
+...
+box.space._space_sequence:update({s.id}, {{'=', 2, t[2]}})
+---
+- error: space "_space_sequence" does not support update
+...
+s:drop()
+---
+...
diff --git a/test/box/sequence.test.lua b/test/box/sequence.test.lua
index b0ec020ed..8e00571e5 100644
--- a/test/box/sequence.test.lua
+++ b/test/box/sequence.test.lua
@@ -771,3 +771,12 @@ sq:next() -- 1
 box.begin() box.space._sequence_data:delete{sq.id} box.rollback()
 sq:next() -- 2
 sq:drop()
+
+--
+-- Update on _space_sequence is forbidden.
+--
+s = box.schema.create_space('test')
+pk = s:create_index('pk', {sequence = true})
+t = box.space._space_sequence:get({s.id})
+box.space._space_sequence:update({s.id}, {{'=', 2, t[2]}})
+s:drop()
-- 
2.21.1 (Apple Git-122.3)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Tarantool-patches] [PATCH 3/3] upgrade: fix generated sequence upgrade from 2.1
  2020-02-17 20:57 [Tarantool-patches] [PATCH 0/3] Fix upgrade from 2.1 sequence Vladislav Shpilevoy
  2020-02-17 20:57 ` [Tarantool-patches] [PATCH 1/3] upgrade: add missing sys triggers off and erasure Vladislav Shpilevoy
  2020-02-17 20:57 ` [Tarantool-patches] [PATCH 2/3] box: forbid to update/replace _space_sequence Vladislav Shpilevoy
@ 2020-02-17 20:57 ` Vladislav Shpilevoy
  2020-02-21 15:42   ` Nikita Pettik
  2020-02-24 19:48 ` [Tarantool-patches] [PATCH 0/3] Fix upgrade from 2.1 sequence Kirill Yukhin
  3 siblings, 1 reply; 11+ messages in thread
From: Vladislav Shpilevoy @ 2020-02-17 20:57 UTC (permalink / raw)
  To: tarantool-patches, alexander.turenko, korablev

The bug was in an attempt to update a record in _space_sequence
in-place, to add field path and number. This was not properly
supported by the system space's trigger, and was banned in the
previous patch of this series.

But delete + tuple update + insert work fine. The patch uses them.

To test it the old disabled and heavily outdated
xlog/upgrade.test.lua was replaced with a smaller analogue, which
is supposed to be created separately for each upgrade bug.
According to the new policy of creating test files.

The patch tries to make it easy to add new upgrade tests and
snapshots. A new test should consist of fill.lua script to
populate spaces, snapshot, needed xlogs, and a .test.lua file.
Fill script and binaries should be in the same folder as test file
name, which is located in version folder. Like this:

 xlog/
 |
 + <test_name>.test.lua
 |
 +- upgrade/
    |
    +- <version>/
    |   |
    |   +-<test_name>/
    |     |
    |     +- fill.lua
    |     +- *.snap
    |     +- *.xlog

Version is supposed to say explicitly what a version files in
there have.

Closes #4771
---
 src/box/lua/upgrade.lua                       |   7 +-
 test/xlog/gh-4771-upgrade.result              |  78 ++++++
 test/xlog/gh-4771-upgrade.test.lua            |  24 ++
 test/xlog/suite.cfg                           |   5 -
 test/xlog/suite.ini                           |   3 +-
 test/xlog/upgrade.result                      | 265 ------------------
 test/xlog/upgrade.test.lua                    |  46 ---
 .../00000000000000000014.snap                 | Bin 0 -> 4622 bytes
 .../2.1.3/gh-4771-upgrade-sequence/fill.lua   |  14 +
 9 files changed, 123 insertions(+), 319 deletions(-)
 create mode 100644 test/xlog/gh-4771-upgrade.result
 create mode 100644 test/xlog/gh-4771-upgrade.test.lua
 delete mode 100644 test/xlog/suite.cfg
 delete mode 100644 test/xlog/upgrade.result
 delete mode 100644 test/xlog/upgrade.test.lua
 create mode 100644 test/xlog/upgrade/2.1.3/gh-4771-upgrade-sequence/00000000000000000014.snap
 create mode 100644 test/xlog/upgrade/2.1.3/gh-4771-upgrade-sequence/fill.lua

diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua
index bd28c1001..4e23aa448 100644
--- a/src/box/lua/upgrade.lua
+++ b/src/box/lua/upgrade.lua
@@ -760,7 +760,12 @@ local function upgrade_sequence_to_2_2_1()
         local part = pk[6][1]
         local field = part.field or part[1]
         local path = part.path or ''
-        _space_sequence:update(v[1], {{'!', 4, field}, {'!', 5, path}})
+        local t = _space_sequence:get(v[1])
+        -- Update in-place is banned due to complexity of its
+        -- handling. Delete + insert still work.
+        t = t:update({{'!', 4, field}, {'!', 5, path}})
+        _space_sequence:delete({v[1]})
+        _space_sequence:insert(t)
         ::continue::
     end
     local format = _space_sequence:format()
diff --git a/test/xlog/gh-4771-upgrade.result b/test/xlog/gh-4771-upgrade.result
new file mode 100644
index 000000000..032ed993a
--- /dev/null
+++ b/test/xlog/gh-4771-upgrade.result
@@ -0,0 +1,78 @@
+-- test-run result file version 2
+test_run = require('test_run').new()
+ | ---
+ | ...
+
+test_run:cmd('create server upgrade with script="xlog/upgrade.lua", '..		\
+             'workdir="xlog/upgrade/2.1.3/gh-4771-upgrade-sequence"')
+ | ---
+ | - true
+ | ...
+test_run:cmd('start server upgrade')
+ | ---
+ | - true
+ | ...
+test_run:switch('upgrade')
+ | ---
+ | - true
+ | ...
+
+box.schema.upgrade()
+ | ---
+ | ...
+
+s = box.space.test1
+ | ---
+ | ...
+box.space._sequence:select{}
+ | ---
+ | - - [1, 1, 'test1_seq', 1, 1, 9223372036854775807, 1, 0, false]
+ |   - [2, 1, 'seq2', 1, 1, 9223372036854775807, 1, 0, false]
+ |   - [3, 1, 'seq3', 1, 1, 9223372036854775807, 1, 0, false]
+ | ...
+box.space._sequence_data:select{}
+ | ---
+ | - - [1, 1]
+ |   - [2, 1]
+ |   - [3, 1]
+ | ...
+box.space._space_sequence:select{}
+ | ---
+ | - - [512, 1, true, 0, '']
+ |   - [513, 2, false, 0, '']
+ | ...
+s:select{}
+ | ---
+ | - - [1]
+ | ...
+_ = s:replace{box.NULL}
+ | ---
+ | ...
+s:select{}
+ | ---
+ | - - [1]
+ |   - [2]
+ | ...
+
+box.space.test2:select{}
+ | ---
+ | - - [1]
+ | ...
+
+box.sequence.seq3:next()
+ | ---
+ | - 2
+ | ...
+
+test_run:switch('default')
+ | ---
+ | - true
+ | ...
+test_run:cmd('stop server upgrade')
+ | ---
+ | - true
+ | ...
+test_run:cmd('delete server upgrade')
+ | ---
+ | - true
+ | ...
diff --git a/test/xlog/gh-4771-upgrade.test.lua b/test/xlog/gh-4771-upgrade.test.lua
new file mode 100644
index 000000000..52334404e
--- /dev/null
+++ b/test/xlog/gh-4771-upgrade.test.lua
@@ -0,0 +1,24 @@
+test_run = require('test_run').new()
+
+test_run:cmd('create server upgrade with script="xlog/upgrade.lua", '..		\
+             'workdir="xlog/upgrade/2.1.3/gh-4771-upgrade-sequence"')
+test_run:cmd('start server upgrade')
+test_run:switch('upgrade')
+
+box.schema.upgrade()
+
+s = box.space.test1
+box.space._sequence:select{}
+box.space._sequence_data:select{}
+box.space._space_sequence:select{}
+s:select{}
+_ = s:replace{box.NULL}
+s:select{}
+
+box.space.test2:select{}
+
+box.sequence.seq3:next()
+
+test_run:switch('default')
+test_run:cmd('stop server upgrade')
+test_run:cmd('delete server upgrade')
diff --git a/test/xlog/suite.cfg b/test/xlog/suite.cfg
deleted file mode 100644
index c33a80ce9..000000000
--- a/test/xlog/suite.cfg
+++ /dev/null
@@ -1,5 +0,0 @@
-{
-    "upgrade.test.lua": {
-        "1.7.7": {"version": "1.7.7"}
-    }
-}
diff --git a/test/xlog/suite.ini b/test/xlog/suite.ini
index 689d2b871..635ec53c1 100644
--- a/test/xlog/suite.ini
+++ b/test/xlog/suite.ini
@@ -2,10 +2,9 @@
 core = tarantool
 description = tarantool write ahead log tests
 script = xlog.lua
-disabled = snap_io_rate.test.lua upgrade.test.lua
+disabled = snap_io_rate.test.lua
 valgrind_disabled =
 release_disabled = errinj.test.lua panic_on_lsn_gap.test.lua panic_on_broken_lsn.test.lua checkpoint_threshold.test.lua
-config = suite.cfg
 use_unix_sockets = True
 use_unix_sockets_iproto = True
 long_run = snap_io_rate.test.lua
diff --git a/test/xlog/upgrade.result b/test/xlog/upgrade.result
deleted file mode 100644
index f64b12d7e..000000000
--- a/test/xlog/upgrade.result
+++ /dev/null
@@ -1,265 +0,0 @@
-test_run = require('test_run').new()
----
-...
-version = test_run:get_cfg('version')
----
-...
-work_dir = "xlog/upgrade/"..version
----
-...
-test_run:cmd('create server upgrade with script="xlog/upgrade.lua", workdir="'..work_dir..'"')
----
-- true
-...
-test_run:cmd("start server upgrade")
----
-- true
-...
-test_run:switch('upgrade')
----
-- true
-...
-test_run:cmd(string.format("push filter '%s' to '<server_uuid>'", box.info.cluster.uuid))
----
-- true
-...
---
--- Upgrade
---
-box.schema.upgrade()
----
-...
---
--- Migrated data
---
-box.space._schema:select()
----
-- - ['cluster', '<server_uuid>']
-  - ['max_id', 513]
-  - ['version', 2, 1, 0]
-...
-box.space._space:select()
----
-- - [257, 1, '_vinyl_deferred_delete', 'blackhole', 0, {'group_id': 1}, [{'name': 'space_id',
-        'type': 'unsigned'}, {'name': 'lsn', 'type': 'unsigned'}, {'name': 'tuple',
-        'type': 'array'}]]
-  - [272, 1, '_schema', 'memtx', 0, {}, [{'type': 'string', 'name': 'key'}]]
-  - [276, 1, '_collation', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'}, {
-        'name': 'name', 'type': 'string'}, {'name': 'owner', 'type': 'unsigned'},
-      {'name': 'type', 'type': 'string'}, {'name': 'locale', 'type': 'string'}, {
-        'name': 'opts', 'type': 'map'}]]
-  - [280, 1, '_space', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'}, {'name': 'owner',
-        'type': 'unsigned'}, {'name': 'name', 'type': 'string'}, {'name': 'engine',
-        'type': 'string'}, {'name': 'field_count', 'type': 'unsigned'}, {'name': 'flags',
-        'type': 'map'}, {'name': 'format', 'type': 'array'}]]
-  - [281, 1, '_vspace', 'sysview', 0, {}, [{'name': 'id', 'type': 'unsigned'}, {'name': 'owner',
-        'type': 'unsigned'}, {'name': 'name', 'type': 'string'}, {'name': 'engine',
-        'type': 'string'}, {'name': 'field_count', 'type': 'unsigned'}, {'name': 'flags',
-        'type': 'map'}, {'name': 'format', 'type': 'array'}]]
-  - [284, 1, '_sequence', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'}, {'name': 'owner',
-        'type': 'unsigned'}, {'name': 'name', 'type': 'string'}, {'name': 'step',
-        'type': 'integer'}, {'name': 'min', 'type': 'integer'}, {'name': 'max', 'type': 'integer'},
-      {'name': 'start', 'type': 'integer'}, {'name': 'cache', 'type': 'integer'},
-      {'name': 'cycle', 'type': 'boolean'}]]
-  - [285, 1, '_sequence_data', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'},
-      {'name': 'value', 'type': 'integer'}]]
-  - [286, 1, '_vsequence', 'sysview', 0, {}, [{'name': 'id', 'type': 'unsigned'},
-      {'name': 'owner', 'type': 'unsigned'}, {'name': 'name', 'type': 'string'}, {
-        'name': 'step', 'type': 'integer'}, {'name': 'min', 'type': 'integer'}, {
-        'name': 'max', 'type': 'integer'}, {'name': 'start', 'type': 'integer'}, {
-        'name': 'cache', 'type': 'integer'}, {'name': 'cycle', 'type': 'boolean'}]]
-  - [288, 1, '_index', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'}, {'name': 'iid',
-        'type': 'unsigned'}, {'name': 'name', 'type': 'string'}, {'name': 'type',
-        'type': 'string'}, {'name': 'opts', 'type': 'map'}, {'name': 'parts', 'type': 'array'}]]
-  - [289, 1, '_vindex', 'sysview', 0, {}, [{'name': 'id', 'type': 'unsigned'}, {'name': 'iid',
-        'type': 'unsigned'}, {'name': 'name', 'type': 'string'}, {'name': 'type',
-        'type': 'string'}, {'name': 'opts', 'type': 'map'}, {'name': 'parts', 'type': 'array'}]]
-  - [296, 1, '_func', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'}, {'name': 'owner',
-        'type': 'unsigned'}, {'name': 'name', 'type': 'string'}, {'name': 'setuid',
-        'type': 'unsigned'}]]
-  - [297, 1, '_vfunc', 'sysview', 0, {}, [{'name': 'id', 'type': 'unsigned'}, {'name': 'owner',
-        'type': 'unsigned'}, {'name': 'name', 'type': 'string'}, {'name': 'setuid',
-        'type': 'unsigned'}]]
-  - [304, 1, '_user', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'}, {'name': 'owner',
-        'type': 'unsigned'}, {'name': 'name', 'type': 'string'}, {'name': 'type',
-        'type': 'string'}, {'name': 'auth', 'type': 'map'}]]
-  - [305, 1, '_vuser', 'sysview', 0, {}, [{'name': 'id', 'type': 'unsigned'}, {'name': 'owner',
-        'type': 'unsigned'}, {'name': 'name', 'type': 'string'}, {'name': 'type',
-        'type': 'string'}, {'name': 'auth', 'type': 'map'}]]
-  - [312, 1, '_priv', 'memtx', 0, {}, [{'name': 'grantor', 'type': 'unsigned'}, {
-        'name': 'grantee', 'type': 'unsigned'}, {'name': 'object_type', 'type': 'string'},
-      {'name': 'object_id', 'type': 'scalar'}, {'name': 'privilege', 'type': 'unsigned'}]]
-  - [313, 1, '_vpriv', 'sysview', 0, {}, [{'name': 'grantor', 'type': 'unsigned'},
-      {'name': 'grantee', 'type': 'unsigned'}, {'name': 'object_type', 'type': 'string'},
-      {'name': 'object_id', 'type': 'scalar'}, {'name': 'privilege', 'type': 'unsigned'}]]
-  - [320, 1, '_cluster', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'}, {'name': 'uuid',
-        'type': 'string'}]]
-  - [328, 1, '_trigger', 'memtx', 0, {}, [{'name': 'name', 'type': 'string'}, {'name': 'opts',
-        'type': 'map'}]]
-  - [330, 1, '_truncate', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'}, {'name': 'count',
-        'type': 'unsigned'}]]
-  - [340, 1, '_space_sequence', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'},
-      {'name': 'sequence_id', 'type': 'unsigned'}, {'name': 'is_generated', 'type': 'boolean'}]]
-  - [348, 1, '_sql_stat1', 'memtx', 0, {}, [{'name': 'tbl', 'type': 'string'}, {'name': 'idx',
-        'type': 'string'}, {'name': 'stat', 'type': 'string'}]]
-  - [349, 1, '_sql_stat4', 'memtx', 0, {}, [{'name': 'tbl', 'type': 'string'}, {'name': 'idx',
-        'type': 'string'}, {'name': 'neq', 'type': 'string'}, {'name': 'nlt', 'type': 'string'},
-      {'name': 'ndlt', 'type': 'string'}, {'name': 'sample', 'type': 'scalar'}]]
-  - [512, 1, 'distro', 'memtx', 0, {}, [{'name': 'os', 'type': 'str'}, {'name': 'dist',
-        'type': 'str'}, {'name': 'version', 'type': 'num'}, {'name': 'time', 'type': 'num'}]]
-  - [513, 1, 'temporary', 'memtx', 0, {'temporary': true}, []]
-...
-box.space._index:select()
----
-- - [272, 0, 'primary', 'tree', {'unique': true}, [[0, 'string']]]
-  - [276, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
-  - [276, 1, 'name', 'tree', {'unique': true}, [[1, 'string']]]
-  - [280, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
-  - [280, 1, 'owner', 'tree', {'unique': false}, [[1, 'unsigned']]]
-  - [280, 2, 'name', 'tree', {'unique': true}, [[2, 'string']]]
-  - [281, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
-  - [281, 1, 'owner', 'tree', {'unique': false}, [[1, 'unsigned']]]
-  - [281, 2, 'name', 'tree', {'unique': true}, [[2, 'string']]]
-  - [284, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
-  - [284, 1, 'owner', 'tree', {'unique': false}, [[1, 'unsigned']]]
-  - [284, 2, 'name', 'tree', {'unique': true}, [[2, 'string']]]
-  - [285, 0, 'primary', 'hash', {'unique': true}, [[0, 'unsigned']]]
-  - [286, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
-  - [286, 1, 'owner', 'tree', {'unique': false}, [[1, 'unsigned']]]
-  - [286, 2, 'name', 'tree', {'unique': true}, [[2, 'string']]]
-  - [288, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned'], [1, 'unsigned']]]
-  - [288, 2, 'name', 'tree', {'unique': true}, [[0, 'unsigned'], [2, 'string']]]
-  - [289, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned'], [1, 'unsigned']]]
-  - [289, 2, 'name', 'tree', {'unique': true}, [[0, 'unsigned'], [2, 'string']]]
-  - [296, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
-  - [296, 1, 'owner', 'tree', {'unique': false}, [[1, 'unsigned']]]
-  - [296, 2, 'name', 'tree', {'unique': true}, [[2, 'string']]]
-  - [297, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
-  - [297, 1, 'owner', 'tree', {'unique': false}, [[1, 'unsigned']]]
-  - [297, 2, 'name', 'tree', {'unique': true}, [[2, 'string']]]
-  - [304, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
-  - [304, 1, 'owner', 'tree', {'unique': false}, [[1, 'unsigned']]]
-  - [304, 2, 'name', 'tree', {'unique': true}, [[2, 'string']]]
-  - [305, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
-  - [305, 1, 'owner', 'tree', {'unique': false}, [[1, 'unsigned']]]
-  - [305, 2, 'name', 'tree', {'unique': true}, [[2, 'string']]]
-  - [312, 0, 'primary', 'tree', {'unique': true}, [[1, 'unsigned'], [2, 'string'],
-      [3, 'scalar']]]
-  - [312, 1, 'owner', 'tree', {'unique': false}, [[0, 'unsigned']]]
-  - [312, 2, 'object', 'tree', {'unique': false}, [[2, 'string'], [3, 'scalar']]]
-  - [313, 0, 'primary', 'tree', {'unique': true}, [[1, 'unsigned'], [2, 'string'],
-      [3, 'scalar']]]
-  - [313, 1, 'owner', 'tree', {'unique': false}, [[0, 'unsigned']]]
-  - [313, 2, 'object', 'tree', {'unique': false}, [[2, 'string'], [3, 'scalar']]]
-  - [320, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
-  - [320, 1, 'uuid', 'tree', {'unique': true}, [[1, 'string']]]
-  - [328, 0, 'primary', 'tree', {'unique': true}, [[0, 'string']]]
-  - [330, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
-  - [340, 0, 'primary', 'tree', {'unique': true}, [[0, 'unsigned']]]
-  - [340, 1, 'sequence', 'tree', {'unique': false}, [[1, 'unsigned']]]
-  - [348, 0, 'primary', 'tree', {'unique': true}, [[0, 'string'], [1, 'string']]]
-  - [349, 0, 'primary', 'tree', {'unique': true}, [[0, 'string'], [1, 'string'], [
-        5, 'scalar']]]
-  - [512, 0, 'primary', 'hash', {'unique': true}, [[0, 'string'], [1, 'string'], [
-        2, 'unsigned']]]
-  - [512, 1, 'codename', 'hash', {'unique': true}, [[1, 'string']]]
-  - [512, 2, 'time', 'tree', {'unique': false}, [[3, 'unsigned']]]
-...
-box.space._user:select()
----
-- - [0, 1, 'guest', 'user', {'chap-sha1': 'vhvewKp0tNyweZQ+cFKAlsyphfg='}]
-  - [1, 1, 'admin', 'user', {}]
-  - [2, 1, 'public', 'role', {}]
-  - [3, 1, 'replication', 'role', {}]
-  - [31, 1, 'super', 'role', {}]
-  - [32, 1, 'someuser', 'user', {'chap-sha1': '2qvbQIHM4zMWhAmm2xGeGNjqoHM='}]
-  - [33, 1, 'somerole', 'role', {}]
-...
-box.space._func:select()
----
-- - [1, 1, 'box.schema.user.info', 1, 'LUA']
-  - [2, 32, 'somefunc', 1, 'LUA']
-  - [3, 1, 'someotherfunc', 0, 'LUA']
-...
-box.space._collation:select()
----
-- - [1, 'unicode', 1, 'ICU', '', {}]
-  - [2, 'unicode_ci', 1, 'ICU', '', {'strength': 'primary'}]
-...
-box.space._priv:select()
----
-- - [1, 0, 'role', 2, 4]
-  - [1, 0, 'universe', 0, 24]
-  - [1, 1, 'universe', 0, 4294967295]
-  - [1, 2, 'function', 1, 4]
-  - [1, 2, 'function', 2, 4]
-  - [1, 2, 'space', 276, 2]
-  - [1, 2, 'space', 281, 1]
-  - [1, 2, 'space', 286, 1]
-  - [1, 2, 'space', 289, 1]
-  - [1, 2, 'space', 297, 1]
-  - [1, 2, 'space', 305, 1]
-  - [1, 2, 'space', 313, 1]
-  - [1, 2, 'space', 330, 2]
-  - [1, 3, 'space', 320, 2]
-  - [1, 3, 'universe', 0, 1]
-  - [1, 31, 'universe', 0, 4294967295]
-  - [1, 32, 'function', 3, 4]
-  - [1, 32, 'role', 2, 4]
-  - [1, 32, 'role', 33, 4]
-  - [1, 32, 'space', 513, 3]
-  - [1, 32, 'universe', 0, 24]
-  - [1, 33, 'space', 512, 3]
-...
-box.space._vspace ~= nil
----
-- true
-...
-box.space._vindex ~= nil
----
-- true
-...
-box.space._vuser ~= nil
----
-- true
-...
-box.space._vpriv ~= nil
----
-- true
-...
--- a test space
-r = box.space.distro:select()
----
-...
-_ = table.sort(r, function(left, right) return tostring(left) < tostring(right) end)
----
-...
-r
----
-- - ['debian', 'etch', 40, 1176019200]
-  - ['debian', 'jessie', 80, 1430038800]
-  - ['debian', 'lenny', 50, 1234602000]
-  - ['debian', 'sarge', 31, 1118044800]
-  - ['debian', 'squeeze', 60, 1296896400]
-  - ['debian', 'wheezy', 70, 1367654400]
-  - ['debian', 'woody', 30, 1027065600]
-  - ['ubuntu', 'precise', 1510, 1335427200]
-  - ['ubuntu', 'trusty', 1404, 1397721600]
-  - ['ubuntu', 'vivid', 1504, 1429779600]
-  - ['ubuntu', 'wily', 1510, 1445504400]
-...
-test_run:cmd("clear filter")
----
-- true
-...
-test_run:switch('default')
----
-- true
-...
-test_run:cmd('stop server upgrade')
----
-- true
-...
-test_run = nil
----
-...
diff --git a/test/xlog/upgrade.test.lua b/test/xlog/upgrade.test.lua
deleted file mode 100644
index 0be2d34e9..000000000
--- a/test/xlog/upgrade.test.lua
+++ /dev/null
@@ -1,46 +0,0 @@
-test_run = require('test_run').new()
-
-version = test_run:get_cfg('version')
-work_dir = "xlog/upgrade/"..version
-
-test_run:cmd('create server upgrade with script="xlog/upgrade.lua", workdir="'..work_dir..'"')
-test_run:cmd("start server upgrade")
-
-test_run:switch('upgrade')
-
-test_run:cmd(string.format("push filter '%s' to '<server_uuid>'", box.info.cluster.uuid))
-
---
--- Upgrade
---
-
-box.schema.upgrade()
-
---
--- Migrated data
---
-
-box.space._schema:select()
-box.space._space:select()
-box.space._index:select()
-box.space._user:select()
-box.space._func:select()
-box.space._collation:select()
-box.space._priv:select()
-
-box.space._vspace ~= nil
-box.space._vindex ~= nil
-box.space._vuser ~= nil
-box.space._vpriv ~= nil
-
--- a test space
-r = box.space.distro:select()
-_ = table.sort(r, function(left, right) return tostring(left) < tostring(right) end)
-r
-
-test_run:cmd("clear filter")
-
-test_run:switch('default')
-test_run:cmd('stop server upgrade')
-
-test_run = nil
diff --git a/test/xlog/upgrade/2.1.3/gh-4771-upgrade-sequence/00000000000000000014.snap b/test/xlog/upgrade/2.1.3/gh-4771-upgrade-sequence/00000000000000000014.snap
new file mode 100644
index 0000000000000000000000000000000000000000..c0d2ef404c4e54377230a3134394dbc7abb5f730
GIT binary patch
literal 4622
zcmV+p67lU*PC-x#FfK7O3RY!ub7^mGIv_GGF)lMLI4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!a~`6bakrF&uPZY+)pxDkL)
zMHVcdeTER+8G^VzD&T<i*fF-`j!=nnQ89;%%Z{-ncZ5oui;6j9Ty~5txg%8KTvW^<
z<AD&Mny|}`D`pPGPR&YL7mxfpzj6(~sJQkes@$*K;zcqFbxdLp8KKt($56|`7_Lm|
zhgVLyL?nLPocsw8GB%ZrJ`-h9w;f6sLbW0ossGo>?@C$cD>Ef8kr7;y*gotp-~iQ}
z-Fq3E7AriRwjh6tQ*V?VBMi(sJ6UwURVIoNYU@OF*PSOuel;JAIX_vqs$L;p7Rt7I
zYYfZ9UI@syg5W%|s0ToREJ{v1>@$v%WH4A<`6E-a``a8Aa&PUtz|xz4KIu)h^KsBV
zJ|%KgO|@i&j`sV*jeMy<otyo(*PbzDavVjB4;5Lkd<YS=F>}pEg?&Kbc^U#f-mIvv
zW{=^De6hPydf0{(r|AQ-dvfDoPK6!<J0A|_O~fIp*hK`(1T|cDKFqq?{uny%)4e$e
zK^63j6j-Le$+Y&<H}*)*BZ>2%q78=ArJR;&ru~>{Usv%()>!j1*2GV))3AiI_&|8N
zFySh!{)B?=N}9Ot^gp{U12F?sX{cWZ+t2A9J8YZH`SX$sBCyewuS7S;;f%jjFMk#7
zjE6b?(p4jHqePWx2sOpdIGbU%f8ESk_xtN6j9zJb7xDD+&bpto?)TSC7`>9L$;P(t
z7o!FYu%1oKE<4fDcNNYmhB^D(`>!K(K;aj=09>n|-^HkB$+wRH^H;)tk`Q9a2h|X*
E?GdQ4X#fBK

literal 0
HcmV?d00001

diff --git a/test/xlog/upgrade/2.1.3/gh-4771-upgrade-sequence/fill.lua b/test/xlog/upgrade/2.1.3/gh-4771-upgrade-sequence/fill.lua
new file mode 100644
index 000000000..b159f2b67
--- /dev/null
+++ b/test/xlog/upgrade/2.1.3/gh-4771-upgrade-sequence/fill.lua
@@ -0,0 +1,14 @@
+box.cfg{}
+s1 = box.schema.create_space('test1')
+pk = s1:create_index('pk', {sequence = true})
+s1:replace{box.NULL}
+
+seq2 = box.schema.sequence.create('seq2')
+s2 = box.schema.create_space('test2')
+pk = s2:create_index('pk', {sequence = 'seq2'})
+s2:replace{box.NULL}
+
+seq3 = box.schema.sequence.create('seq3')
+seq3:next()
+
+box.snapshot()
-- 
2.21.1 (Apple Git-122.3)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Tarantool-patches] [PATCH 1/3] upgrade: add missing sys triggers off and erasure
  2020-02-17 20:57 ` [Tarantool-patches] [PATCH 1/3] upgrade: add missing sys triggers off and erasure Vladislav Shpilevoy
@ 2020-02-21 15:20   ` Nikita Pettik
  2020-02-22 16:17     ` Vladislav Shpilevoy
  0 siblings, 1 reply; 11+ messages in thread
From: Nikita Pettik @ 2020-02-21 15:20 UTC (permalink / raw)
  To: Vladislav Shpilevoy; +Cc: tarantool-patches

On 17 Feb 21:57, Vladislav Shpilevoy wrote:

LGTM

> +local function foreach_system_space(cb)
> +    local max = box.schema.SYSTEM_ID_MAX
> +    for id, space in pairs(box.space) do

Nit: I'd add brief comment explaining that here we are interested
only in 'native' system spaces skipping sysviews etc.

> +        if type(id) == 'number' and
> +           (space.engine == 'memtx' or space.engine == 'vinyl') then
> +            if id > max then
> +                break
> +            end
> +            cb(space)
> +        end
> +    end
> +end
> +
>  local function set_system_triggers(val)
> -    box.space._space:run_triggers(val)
> -    box.space._index:run_triggers(val)
> -    box.space._user:run_triggers(val)
> -    box.space._func:run_triggers(val)
> -    box.space._priv:run_triggers(val)
> -    box.space._trigger:run_triggers(val)
> -    box.space._collation:run_triggers(val)
> -    box.space._schema:run_triggers(val)
> -    box.space._cluster:run_triggers(val)
> -    box.space._fk_constraint:run_triggers(val)
> -    box.space._ck_constraint:run_triggers(val)
> +    foreach_system_space(function(s) s:run_triggers(val) end)
>  end
>  

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Tarantool-patches] [PATCH 2/3] box: forbid to update/replace _space_sequence
  2020-02-17 20:57 ` [Tarantool-patches] [PATCH 2/3] box: forbid to update/replace _space_sequence Vladislav Shpilevoy
@ 2020-02-21 15:29   ` Nikita Pettik
  2020-02-22 16:16     ` Vladislav Shpilevoy
  0 siblings, 1 reply; 11+ messages in thread
From: Nikita Pettik @ 2020-02-21 15:29 UTC (permalink / raw)
  To: Vladislav Shpilevoy; +Cc: tarantool-patches

On 17 Feb 21:57, Vladislav Shpilevoy wrote:
> diff --git a/src/box/alter.cc b/src/box/alter.cc
> index 64af71c61..50121c79c 100644
> --- a/src/box/alter.cc
> +++ b/src/box/alter.cc
> @@ -4713,9 +4713,13 @@ on_replace_dd_space_sequence(struct trigger * /* trigger */, void *event)
>  		return -1;
>  	}

LGTM

Nit: as always I'd only add brief comment like:

/* UPDATE operation is considered to meaningless for _space_sequence
   since ...

*/
  
> +	if ((stmt->new_tuple != NULL) == (stmt->old_tuple != NULL)) {
> +		diag_set(ClientError, ER_UNSUPPORTED,
> +			 "space \"_space_sequence\"", "update");
> +		return -1;
> +	}
> +
>  	enum priv_type priv_type = stmt->new_tuple ? PRIV_C : PRIV_D;
> -	if (stmt->new_tuple && stmt->old_tuple)
> -		priv_type = PRIV_A;
>  
>  	/* Check we have the correct access type on the sequence.  * */
>  	if (is_generated || !stmt->new_tuple) {

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Tarantool-patches] [PATCH 3/3] upgrade: fix generated sequence upgrade from 2.1
  2020-02-17 20:57 ` [Tarantool-patches] [PATCH 3/3] upgrade: fix generated sequence upgrade from 2.1 Vladislav Shpilevoy
@ 2020-02-21 15:42   ` Nikita Pettik
  2020-02-22 16:16     ` Vladislav Shpilevoy
  0 siblings, 1 reply; 11+ messages in thread
From: Nikita Pettik @ 2020-02-21 15:42 UTC (permalink / raw)
  To: Vladislav Shpilevoy; +Cc: tarantool-patches

On 17 Feb 21:57, Vladislav Shpilevoy wrote:
> The bug was in an attempt to update a record in _space_sequence
> in-place, to add field path and number. This was not properly
> supported by the system space's trigger, and was banned in the
> previous patch of this series.
> 
> But delete + tuple update + insert work fine. The patch uses them.
> 
> To test it the old disabled and heavily outdated
> xlog/upgrade.test.lua was replaced with a smaller analogue, which
> is supposed to be created separately for each upgrade bug.
> According to the new policy of creating test files.
> 
> The patch tries to make it easy to add new upgrade tests and
> snapshots. A new test should consist of fill.lua script to
> populate spaces, snapshot, needed xlogs, and a .test.lua file.
> Fill script and binaries should be in the same folder as test file
> name, which is located in version folder. Like this:

I'm okay with this approach but could you document it somewhere
(e.g. on our wiki github page)?

>  xlog/
>  |
>  + <test_name>.test.lua
>  |
>  +- upgrade/
>     |
>     +- <version>/
>     |   |
>     |   +-<test_name>/
>     |     |
>     |     +- fill.lua
>     |     +- *.snap
>     |     +- *.xlog
> 
> Version is supposed to say explicitly what a version files in
> there have.

Patch itself is LGTM.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Tarantool-patches] [PATCH 3/3] upgrade: fix generated sequence upgrade from 2.1
  2020-02-21 15:42   ` Nikita Pettik
@ 2020-02-22 16:16     ` Vladislav Shpilevoy
  0 siblings, 0 replies; 11+ messages in thread
From: Vladislav Shpilevoy @ 2020-02-22 16:16 UTC (permalink / raw)
  To: Nikita Pettik; +Cc: tarantool-patches

Thanks for the review!

On 21/02/2020 16:42, Nikita Pettik wrote:
> On 17 Feb 21:57, Vladislav Shpilevoy wrote:
>> The bug was in an attempt to update a record in _space_sequence
>> in-place, to add field path and number. This was not properly
>> supported by the system space's trigger, and was banned in the
>> previous patch of this series.
>>
>> But delete + tuple update + insert work fine. The patch uses them.
>>
>> To test it the old disabled and heavily outdated
>> xlog/upgrade.test.lua was replaced with a smaller analogue, which
>> is supposed to be created separately for each upgrade bug.
>> According to the new policy of creating test files.
>>
>> The patch tries to make it easy to add new upgrade tests and
>> snapshots. A new test should consist of fill.lua script to
>> populate spaces, snapshot, needed xlogs, and a .test.lua file.
>> Fill script and binaries should be in the same folder as test file
>> name, which is located in version folder. Like this:
> 
> I'm okay with this approach but could you document it somewhere
> (e.g. on our wiki github page)?

Ok, added a file with instructions to xlog/upgrade. I decided not to
add it to wiki, because anyway no one reads it, when just wants to add
a test. There is a higher chance, that this file will be noticed.

diff --git a/test/xlog/upgrade/how_to_add_new_test.md b/test/xlog/upgrade/how_to_add_new_test.md
new file mode 100644
index 000000000..3fa3c2d44
--- /dev/null
+++ b/test/xlog/upgrade/how_to_add_new_test.md
@@ -0,0 +1,36 @@
+## How to add a new upgrade test
+
+Firstly, for a new test should be prepared a `fill.lua` file. Here
+should be code to populate needed spaces, create xlogs, snapshots.
+
+`Fill.lua` should be run in an old Tarantool version, upgrade from
+which is going to be tested. This will produce `.xlog` and `.snap`
+files. They should be saved into
+`xlog/upgrade/<version>/<test_name>/` folder. Snapshot is usually
+enough. Version is the old Tarantool version. Test name is a name
+of test file, which will test recovery from these xlogs. It should
+obey to the same rules as other test file names.
+
+Secondly, it is necessary to add a `<test_name>.test.lua` file to
+`xlog/` folder, to all the other tests. It should start a new
+instance of Tarantool with workdir set to
+`xlog/upgrade/<version>/<test_name>/`. Then this file should
+ensure, that `box.upgrade()` works fine, and all data is recovered
+correctly.
+
+The following directory structure should be in the result:
+```
+ xlog/
+ |
+ +- <test_name>.test.lua
+ |
+ +- upgrade/
+    |
+    +- <version>/
+        |
+        +- <test_name>/
+           |
+           +- fill.lua
+           +- *.snap
+           +- *.xlog
+```

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Tarantool-patches] [PATCH 2/3] box: forbid to update/replace _space_sequence
  2020-02-21 15:29   ` Nikita Pettik
@ 2020-02-22 16:16     ` Vladislav Shpilevoy
  0 siblings, 0 replies; 11+ messages in thread
From: Vladislav Shpilevoy @ 2020-02-22 16:16 UTC (permalink / raw)
  To: Nikita Pettik; +Cc: tarantool-patches

Thanks for the review!

On 21/02/2020 16:29, Nikita Pettik wrote:
> On 17 Feb 21:57, Vladislav Shpilevoy wrote:
>> diff --git a/src/box/alter.cc b/src/box/alter.cc
>> index 64af71c61..50121c79c 100644
>> --- a/src/box/alter.cc
>> +++ b/src/box/alter.cc
>> @@ -4713,9 +4713,13 @@ on_replace_dd_space_sequence(struct trigger * /* trigger */, void *event)
>>  		return -1;
>>  	}
> 
> LGTM
> 
> Nit: as always I'd only add brief comment like:

Done. New hunk is below. Also I changed

    (stmt->new_tuple != NULL) == (stmt->old_tuple != NULL)

to

    stmt->new_tuple != NULL && stmt->old_tuple != NULL

Because both of the tuples can't be NULL anyway.

diff --git a/src/box/alter.cc b/src/box/alter.cc
index 64af71c61..d73679fb8 100644
--- a/src/box/alter.cc
+++ b/src/box/alter.cc
@@ -4712,10 +4712,17 @@ on_replace_dd_space_sequence(struct trigger * /* trigger */, void *event)
 		diag_set(ClientError, ER_NO_SUCH_SEQUENCE, int2str(sequence_id));
 		return -1;
 	}
-
+	if (stmt->new_tuple != NULL && stmt->old_tuple != NULL) {
+		/*
+		 * Makes no sense to support update, it would
+		 * complicate the code, and won't simplify
+		 * anything else.
+		 */
+		diag_set(ClientError, ER_UNSUPPORTED,
+			 "space \"_space_sequence\"", "update");
+		return -1;
+	}
 	enum priv_type priv_type = stmt->new_tuple ? PRIV_C : PRIV_D;
-	if (stmt->new_tuple && stmt->old_tuple)
-		priv_type = PRIV_A;

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Tarantool-patches] [PATCH 1/3] upgrade: add missing sys triggers off and erasure
  2020-02-21 15:20   ` Nikita Pettik
@ 2020-02-22 16:17     ` Vladislav Shpilevoy
  0 siblings, 0 replies; 11+ messages in thread
From: Vladislav Shpilevoy @ 2020-02-22 16:17 UTC (permalink / raw)
  To: Nikita Pettik; +Cc: tarantool-patches

Hi! Thanks for the review!

On 21/02/2020 16:20, Nikita Pettik wrote:
> On 17 Feb 21:57, Vladislav Shpilevoy wrote:
> 
> LGTM
> 
>> +local function foreach_system_space(cb)
>> +    local max = box.schema.SYSTEM_ID_MAX
>> +    for id, space in pairs(box.space) do
> 
> Nit: I'd add brief comment explaining that here we are interested
> only in 'native' system spaces skipping sysviews etc.

Done. Also I decided not to break, when see a space id > SYSTEM_ID_MAX,
because box.space is not an array. And it is not safe to assume, that
all numeric indexes here are in ascending order.

diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua
index bd28c1001..2f029d8c0 100644
--- a/src/box/lua/upgrade.lua
+++ b/src/box/lua/upgrade.lua
@@ -66,11 +66,18 @@ end
 local function foreach_system_space(cb)
     local max = box.schema.SYSTEM_ID_MAX
     for id, space in pairs(box.space) do
-        if type(id) == 'number' and
+        -- Check for number, because box.space contains each space
+        -- twice - by ID and by name. Here IDs are selected.
+        -- Engine is checked to be a 'native' space, because other
+        -- engines does not support DML, and does not have
+        -- triggers to turn off/on. These are 'service',
+        -- 'blackhole', and more may be added.
+        -- When id > max system id is met, break is not done,
+        -- because box.space is not an array, and it is not safe
+        -- to assume all its numeric indexes are returned in
+        -- ascending order.
+        if type(id) == 'number' and id <= max and
            (space.engine == 'memtx' or space.engine == 'vinyl') then
-            if id > max then
-                break
-            end
             cb(space)
         end
     end

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Tarantool-patches] [PATCH 0/3] Fix upgrade from 2.1 sequence
  2020-02-17 20:57 [Tarantool-patches] [PATCH 0/3] Fix upgrade from 2.1 sequence Vladislav Shpilevoy
                   ` (2 preceding siblings ...)
  2020-02-17 20:57 ` [Tarantool-patches] [PATCH 3/3] upgrade: fix generated sequence upgrade from 2.1 Vladislav Shpilevoy
@ 2020-02-24 19:48 ` Kirill Yukhin
  3 siblings, 0 replies; 11+ messages in thread
From: Kirill Yukhin @ 2020-02-24 19:48 UTC (permalink / raw)
  To: Vladislav Shpilevoy; +Cc: tarantool-patches

Hello,

On 17 фев 21:57, Vladislav Shpilevoy wrote:
> The patchset fixes inability to upgrade from 2.1 if there is an
> automatically generated sequence. The problem was that upgrade
> tried to update a tuple in _space_sequence in-place, calling
> space:update() method. But it was not properly supported for
> _space_sequence. The patchset turns it into delete + insert, and
> bans updates for this space.
> 
> Branch: http://github.com/tarantool/tarantool/tree/gerold103/gh-4771-2.2-upgrade
> Issue: https://github.com/tarantool/tarantool/issues/4771

I've checked your patch into 2.2, 2.3 and master.

--
Regards, Kirill Yukhin

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-02-24 19:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-17 20:57 [Tarantool-patches] [PATCH 0/3] Fix upgrade from 2.1 sequence Vladislav Shpilevoy
2020-02-17 20:57 ` [Tarantool-patches] [PATCH 1/3] upgrade: add missing sys triggers off and erasure Vladislav Shpilevoy
2020-02-21 15:20   ` Nikita Pettik
2020-02-22 16:17     ` Vladislav Shpilevoy
2020-02-17 20:57 ` [Tarantool-patches] [PATCH 2/3] box: forbid to update/replace _space_sequence Vladislav Shpilevoy
2020-02-21 15:29   ` Nikita Pettik
2020-02-22 16:16     ` Vladislav Shpilevoy
2020-02-17 20:57 ` [Tarantool-patches] [PATCH 3/3] upgrade: fix generated sequence upgrade from 2.1 Vladislav Shpilevoy
2020-02-21 15:42   ` Nikita Pettik
2020-02-22 16:16     ` Vladislav Shpilevoy
2020-02-24 19:48 ` [Tarantool-patches] [PATCH 0/3] Fix upgrade from 2.1 sequence Kirill Yukhin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox