From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp45.i.mail.ru (smtp45.i.mail.ru [94.100.177.105]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 2AB324696C3 for ; Sat, 22 Feb 2020 19:17:08 +0300 (MSK) References: <2637883c072d078cf970a90a9d5b21164380ebd1.1581972845.git.v.shpilevoy@tarantool.org> <20200221152023.GC51816@tarantool.org> From: Vladislav Shpilevoy Message-ID: <193460a0-ad68-a587-9598-3fa833c4c68d@tarantool.org> Date: Sat, 22 Feb 2020 17:17:05 +0100 MIME-Version: 1.0 In-Reply-To: <20200221152023.GC51816@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH 1/3] upgrade: add missing sys triggers off and erasure List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Nikita Pettik Cc: tarantool-patches@dev.tarantool.org 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