From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id D6D256F873; Fri, 28 Jan 2022 03:23:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D6D256F873 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1643329434; bh=Y+AI5gUe/u/VyeLAYoEwIEn6b+HObfVKHmob5bbz/Mw=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=TP75SdDBKLIZ7LFPsitJ7JrD0baswrXEjquPfTnmJyaU6LkQbsKa7Ua5hJD74slkV wZGbFEINBfPLUTxcIklRAylufJ2CEOi7PWh3f//7QXuoXa+eOj9VEq/k0HlNB6V3wC jl9kqHy2hGTirwRVUdm3154bun1smFq2ir16s/q4= Received: from smtpng3.i.mail.ru (smtpng3.i.mail.ru [94.100.177.149]) (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 28C3B6F873 for ; Fri, 28 Jan 2022 03:23:20 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 28C3B6F873 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1nDF2t-0003Tl-EY; Fri, 28 Jan 2022 03:23:19 +0300 To: tarantool-patches@dev.tarantool.org, olegrok@tarantool.org Date: Fri, 28 Jan 2022 01:23:16 +0100 Message-Id: <4027b571e5f7b9edbf9e153f127e2d1172cc2647.1643329358.git.v.shpilevoy@tarantool.org> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9AA78FDF62ECAE61F27013EC9534AAA53678E560D4B152BF1182A05F538085040C6093B96E0A9E70CA2495BC2FA2665F84B8CB9809C03380F0FF893F5C9DFF2B8 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE71BDE6A359BD5B800EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637CB87E27B59CE093D8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D871722379FC5D77A334A79DB0D46291D6117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD182CC0D3CB04F14752D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6300D3B61E77C8D3B089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C86C5B328D8C3BEB65191654559B2BA3AA3503901F9DF6A689C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EFF7EC8CC465A83DA3699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3416EA6E382A5BB176515B1F1C9A4DE099BAAA8C012D8C6C4F98BE43DC3F9C816F4E8BB8480AE7561F1D7E09C32AA3244CAC6503AF56E3BCBCBA30D59D2F1A8F679CA7333006C390A0729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojqLK0kLh8sGdMNvBoIMsZ0Q== X-Mailru-Sender: 689FA8AB762F739339CABD9B3CA9A7D697F4EE85D0D5B6EA5A4C8B37BBDD38A13841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E25FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: [Tarantool-patches] [PATCH vshard 1/2] Drop Tarantool < 1.10.1 support X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" The reasons are: - Rebalancer won't work. It uses fiber.join(). - Bucket discovery on router is extra expensive - it downloads the entire _bucket from each storage. That can make the latter and the router unresponsive for notable time if bucket count is big enough. - There are other minor hacks which complicate development. For instance, box.error.new() couldn't be used. - Tests don't pass. Thus can't tell what else is broken. Makes no sense to support it if it can't be even tested properly The reason why it is done now is because the code will get more complicated soon and will use more new features which even 1.10 won't support. This patch should reduce the level of version dependency complications before they get even worse. Closes #256 Closes #267 @TarantoolBot document Title: VShard now supports only Tarantool >= 1.10.1 It used to support 1.9 too, but now it is dropped. To use VShard > 0.1.19 a user needs Tarantool >= 1.10.1. --- vshard/cfg.lua | 5 ---- vshard/error.lua | 9 ++---- vshard/router/init.lua | 65 ++--------------------------------------- vshard/storage/init.lua | 21 ++----------- vshard/util.lua | 4 +++ 5 files changed, 13 insertions(+), 91 deletions(-) diff --git a/vshard/cfg.lua b/vshard/cfg.lua index a059d44..1903967 100644 --- a/vshard/cfg.lua +++ b/vshard/cfg.lua @@ -2,7 +2,6 @@ local log = require('log') local luri = require('uri') -local lutil = require('vshard.util') local consts = require('vshard.consts') local function check_uri(uri) @@ -22,10 +21,6 @@ local function check_replica_master(master, ctx) end local function check_replicaset_master(master, ctx) - -- Limit the version due to extensive usage of netbox is_async feature. - if not lutil.version_is_at_least(1, 10, 1) then - error('Only versions >= 1.10.1 support master discovery') - end if master ~= 'auto' then error('Only "auto" master is supported') end diff --git a/vshard/error.lua b/vshard/error.lua index c673827..d36803a 100644 --- a/vshard/error.lua +++ b/vshard/error.lua @@ -235,8 +235,7 @@ local function make_error(e) -- box.error, return unpacked return box_error(e) elseif type(e) == 'string' then - local ok, err = pcall(box.error, box.error.PROC_LUA, e) - return box_error(err) + return box_error(box.error.new(box.error.PROC_LUA, e)) elseif type(e) == 'table' then return setmetatable(e, {__tostring = json.encode}) else @@ -271,12 +270,10 @@ local function make_alert(code, ...) end -- --- Create a timeout error object. Box.error.new() can't be used because is --- present only since 1.10. +-- Create a timeout error object. -- local function make_timeout() - local _, err = pcall(box.error, box.error.TIMEOUT) - return make_error(err) + return make_error(box.error.new(box.error.TIMEOUT)) end return { diff --git a/vshard/router/init.lua b/vshard/router/init.lua index 5a94a2f..ebeaac9 100644 --- a/vshard/router/init.lua +++ b/vshard/router/init.lua @@ -249,15 +249,10 @@ local function discovery_handle_buckets(router, replicaset, buckets) end end -local discovery_f - -if util.version_is_at_least(1, 10, 0) then -- --- >= 1.10 version of discovery fiber does parallel discovery of --- all replicasets at once. It uses is_async feature of netbox --- for that. +-- Bucket discovery main loop. -- -discovery_f = function(router) +local function discovery_f(router) local module_version = M.module_version assert(router.discovery_mode == 'on' or router.discovery_mode == 'once') local iterators = {} @@ -394,47 +389,6 @@ discovery_f = function(router) end end --- Version >= 1.10. -else --- Version < 1.10. - --- --- Background fiber to perform discovery. It periodically scans --- replicasets one by one and updates route_map. --- -discovery_f = function(router) - local module_version = M.module_version - while module_version == M.module_version do - while not next(router.replicasets) do - lfiber.sleep(consts.DISCOVERY_IDLE_INTERVAL) - end - local old_replicasets = router.replicasets - for rs_uuid, replicaset in pairs(router.replicasets) do - local active_buckets, err = - replicaset:callro('vshard.storage.buckets_discovery', {}, - {timeout = 2}) - while M.errinj.ERRINJ_LONG_DISCOVERY do - M.errinj.ERRINJ_LONG_DISCOVERY = 'waiting' - lfiber.sleep(0.01) - end - -- Renew replicasets object captured by the for loop - -- in case of reconfigure and reload events. - if router.replicasets ~= old_replicasets then - break - end - if not active_buckets then - log.error('Error during discovery %s: %s', replicaset, err) - else - discovery_handle_buckets(router, replicaset, active_buckets) - end - lfiber.sleep(consts.DISCOVERY_IDLE_INTERVAL) - end - end -end - --- Version < 1.10. -end - -- -- Immediately wakeup discovery fiber if exists. -- @@ -758,9 +712,6 @@ local function router_call(router, bucket_id, opts, ...) ...) end -local router_map_callrw - -if util.version_is_at_least(1, 10, 0) then -- -- Consistent Map-Reduce. The given function is called on all masters in the -- cluster with a guarantee that in case of success it was executed with all @@ -800,7 +751,7 @@ if util.version_is_at_least(1, 10, 0) then -- about concrete replicaset. For example, not all buckets were found even -- though all replicasets were scanned. -- -router_map_callrw = function(router, func, args, opts) +local function router_map_callrw(router, func, args, opts) local replicasets = router.replicasets local timeout = opts and opts.timeout or consts.CALL_TIMEOUT_MIN local deadline = fiber_clock() + timeout @@ -919,16 +870,6 @@ router_map_callrw = function(router, func, args, opts) return nil, err, err_uuid end --- Version >= 1.10. -else --- Version < 1.10. - -router_map_callrw = function() - error('Supported for Tarantool >= 1.10') -end - -end - -- -- Get replicaset object by bucket identifier. -- @param bucket_id Bucket identifier. diff --git a/vshard/storage/init.lua b/vshard/storage/init.lua index 3eaad9c..78103cf 100644 --- a/vshard/storage/init.lua +++ b/vshard/storage/init.lua @@ -1288,11 +1288,8 @@ local function bucket_recv_xc(bucket_id, from, data, opts) local space_name, space_data = row[1], row[2] local space = box.space[space_name] if space == nil then - -- Tarantool doesn't provide API to create box.error - -- objects before 1.10. - local _, boxerror = pcall(box.error, box.error.NO_SUCH_SPACE, - space_name) - return nil, lerror.box(boxerror) + local err = box.error.new(box.error.NO_SUCH_SPACE, space_name) + return nil, lerror.box(err) end box.begin() for _, tuple in ipairs(space_data) do @@ -2209,13 +2206,6 @@ end -- local function rebalancer_worker_f(worker_id, dispenser, quit_cond) lfiber.name(string.format('vshard.rebalancer_worker_%d', worker_id)) - if not util.version_is_at_least(1, 10, 0) then - -- Return control to the caller immediately to allow it - -- to finish preparations. In 1.9 a caller couldn't create - -- a fiber without switching to it. - lfiber.yield() - end - local _status = box.space._bucket.index.status local opts = {timeout = consts.REBALANCER_CHUNK_TIMEOUT} local active_key = {consts.BUCKET.ACTIVE} @@ -2299,12 +2289,7 @@ local function rebalancer_apply_routes_f(routes) local quit_cond = lfiber.cond() local workers = table.new(worker_count, 0) for i = 1, worker_count do - local f - if util.version_is_at_least(1, 10, 0) then - f = lfiber.new(rebalancer_worker_f, i, dispenser, quit_cond) - else - f = lfiber.create(rebalancer_worker_f, i, dispenser, quit_cond) - end + local f = lfiber.new(rebalancer_worker_f, i, dispenser, quit_cond) f:set_joinable(true) workers[i] = f end diff --git a/vshard/util.lua b/vshard/util.lua index afa658b..366fdea 100644 --- a/vshard/util.lua +++ b/vshard/util.lua @@ -154,6 +154,10 @@ local function version_is_at_least(major_need, middle_need, minor_need) return minor >= minor_need end +if not version_is_at_least(1, 10, 1) then + error("VShard supports only Tarantool >= 1.10.1") +end + -- -- Copy @a src table. Fiber yields every @a interval keys copied. Does not give -- any guarantees on what is the result when the source table is changed during -- 2.24.3 (Apple Git-128)