From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp43.i.mail.ru (smtp43.i.mail.ru [94.100.177.103]) (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 1F7C2442BB3 for ; Sat, 21 Mar 2020 21:59:30 +0300 (MSK) From: Vladislav Shpilevoy Date: Sat, 21 Mar 2020 19:59:26 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH vshard 2/2] storage: introduce vshard.storage._call() List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org, olegrok@tarantool.org, yaroslav.dynnikov@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)