From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: tarantool-patches@dev.tarantool.org, alexander.turenko@tarantool.org, korablev@tarantool.org Subject: [Tarantool-patches] [PATCH 1/3] upgrade: add missing sys triggers off and erasure Date: Mon, 17 Feb 2020 21:57:20 +0100 [thread overview] Message-ID: <2637883c072d078cf970a90a9d5b21164380ebd1.1581972845.git.v.shpilevoy@tarantool.org> (raw) In-Reply-To: <cover.1581972845.git.v.shpilevoy@tarantool.org> 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)
next prev parent reply other threads:[~2020-02-17 20:57 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 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 [this message] 2020-02-21 15:20 ` [Tarantool-patches] [PATCH 1/3] upgrade: add missing sys triggers off and erasure 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
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=2637883c072d078cf970a90a9d5b21164380ebd1.1581972845.git.v.shpilevoy@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=alexander.turenko@tarantool.org \ --cc=korablev@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 1/3] upgrade: add missing sys triggers off and erasure' \ /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