From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: tarantool-patches@dev.tarantool.org, olegrok@tarantool.org, yaroslav.dynnikov@tarantool.org Subject: [Tarantool-patches] [PATCH vshard 2/2] storage: introduce vshard.storage._call() Date: Sat, 21 Mar 2020 19:59:26 +0100 [thread overview] Message-ID: <f68117750f221d0fe67134bd5058ac3c92db5be7.1584817081.git.v.shpilevoy@tarantool.org> (raw) In-Reply-To: <cover.1584817081.git.v.shpilevoy@tarantool.org> It is a new internal function which is supposed to absorb all the other internal functions to make it easier to change them, to simplify adding new and drop old functions. This also hides them from vshard.storage.* namespace so users can't try to use them not knowing they are private. Additionally, _call() allows to change internal function set even on read-only instances, because it has nothing to do with the schema. Internal function set can be updated by reload. Closes #227 Part of #210 --- _call can't be properly integrated at this moment, because that would break rebalancing from old nodes. The new function is only added. Its usage and drop of old functions will happen in 0.1.17 when I will finish and merge top commit from this branch: https://github.com/tarantool/vshard/tree/gerold103/gh-227-drop-old-functions test/upgrade/upgrade.result | 12 ++++++++++++ test/upgrade/upgrade.test.lua | 3 +++ vshard/storage/init.lua | 26 ++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/test/upgrade/upgrade.result b/test/upgrade/upgrade.result index 0fb68c7..6c9bf2c 100644 --- a/test/upgrade/upgrade.result +++ b/test/upgrade/upgrade.result @@ -92,6 +92,10 @@ vshard.storage.internal.schema_latest_version | --- | - null | ... +vshard.storage._call == nil + | --- + | - true + | ... bucket_count = vshard.consts.DEFAULT_BUCKET_COUNT / 2 | --- | ... @@ -157,6 +161,10 @@ vshard.storage.internal.schema_latest_version | - 16 | - 0 | ... +vshard.storage._call ~= nil + | --- + | - true + | ... test_run:switch('storage_1_b') | --- @@ -180,6 +188,10 @@ vshard.storage.internal.schema_latest_version | - 16 | - 0 | ... +vshard.storage._call ~= nil + | --- + | - true + | ... test_run:switch('default') | --- diff --git a/test/upgrade/upgrade.test.lua b/test/upgrade/upgrade.test.lua index 3a4d113..422920e 100644 --- a/test/upgrade/upgrade.test.lua +++ b/test/upgrade/upgrade.test.lua @@ -31,6 +31,7 @@ test_run:switch('storage_2_a') box.space._schema:get({'oncevshard:storage:1'}) or box.space._schema:select() vshard.storage.internal.schema_current_version vshard.storage.internal.schema_latest_version +vshard.storage._call == nil bucket_count = vshard.consts.DEFAULT_BUCKET_COUNT / 2 first_bucket = vshard.consts.DEFAULT_BUCKET_COUNT / 2 + 1 vshard.storage.bucket_force_create(first_bucket, bucket_count) @@ -51,11 +52,13 @@ test_run:switch('storage_1_a') box.space._schema:get({'vshard_version'}) vshard.storage.internal.schema_current_version() vshard.storage.internal.schema_latest_version +vshard.storage._call ~= nil test_run:switch('storage_1_b') box.space._schema:get({'vshard_version'}) vshard.storage.internal.schema_current_version() vshard.storage.internal.schema_latest_version +vshard.storage._call ~= nil test_run:switch('default') -- Main purpose of the test - ensure that data can be safely moved diff --git a/vshard/storage/init.lua b/vshard/storage/init.lua index a87a50b..0af075b 100644 --- a/vshard/storage/init.lua +++ b/vshard/storage/init.lua @@ -325,6 +325,20 @@ local function schema_upgrade_to_0_1_16_0(username) log.info('Insert vshard_version into _schema') box.space._schema:replace({'vshard_version', 0, 1, 16, 0}) box.space._schema:delete({'oncevshard:storage:1'}) + + -- vshard.storage._call() is supposed to replace some internal + -- functions exposed in _func; to allow introduction of new + -- functions on replicas; to allow change of internal + -- functions without touching the schema. + local func = 'vshard.storage._call' + log.info('Create function %s()', func) + box.schema.func.create(func, {setuid = true}) + box.schema.user.grant(username, 'execute', 'function', func) + -- Don't drop old functions in the same version. Removal can + -- happen only after 0.1.16. Or there should appear support of + -- rebalancing from too old versions. Drop of these functions + -- now would immediately make it impossible to rebalance from + -- old instances. end local function schema_current_version() @@ -2154,6 +2168,17 @@ local function storage_call(bucket_id, mode, name, args) return ok, ret1, ret2, ret3 end +local service_call_api = { + bucket_recv = bucket_recv, + rebalancer_apply_routes = rebalancer_apply_routes, + rebalancer_request_state = rebalancer_request_state, +} + +local function service_call(...) + local service_name = select(1, ...) + return service_call_api[service_name](select(2, ...)) +end + -------------------------------------------------------------------------------- -- Configuration -------------------------------------------------------------------------------- @@ -2609,6 +2634,7 @@ return { rebalancing_is_in_progress = rebalancing_is_in_progress, recovery_wakeup = recovery_wakeup, call = storage_call, + _call = service_call, cfg = function(cfg, uuid) return storage_cfg(cfg, uuid, false) end, info = storage_info, buckets_info = storage_buckets_info, -- 2.21.1 (Apple Git-122.3)
next prev parent reply other threads:[~2020-03-21 18:59 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-03-21 18:59 [Tarantool-patches] [PATCH vshard 0/2] vshard upgrade and _call Vladislav Shpilevoy 2020-03-21 18:59 ` [Tarantool-patches] [PATCH vshard 1/2] storage: introduce upgrade strategy Vladislav Shpilevoy 2020-03-22 5:05 ` Oleg Babin 2020-03-22 19:12 ` Vladislav Shpilevoy 2020-03-23 6:35 ` Oleg Babin 2020-03-23 22:32 ` Vladislav Shpilevoy 2020-03-24 4:32 ` Oleg Babin 2020-03-24 15:21 ` Yaroslav Dynnikov 2020-03-24 23:44 ` Vladislav Shpilevoy 2020-03-21 18:59 ` Vladislav Shpilevoy [this message] 2020-03-22 5:08 ` [Tarantool-patches] [PATCH vshard 2/2] storage: introduce vshard.storage._call() Oleg Babin 2020-03-22 19:13 ` Vladislav Shpilevoy 2020-03-23 6:42 ` Oleg Babin 2020-03-23 22:32 ` Vladislav Shpilevoy
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=f68117750f221d0fe67134bd5058ac3c92db5be7.1584817081.git.v.shpilevoy@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=olegrok@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --cc=yaroslav.dynnikov@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH vshard 2/2] storage: introduce vshard.storage._call()' \ /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