[Tarantool-patches] [PATCH 1/3] upgrade: add missing sys triggers off and erasure

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sat Feb 22 19:17:05 MSK 2020


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


More information about the Tarantool-patches mailing list