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 C1D306EC40; Tue, 6 Jul 2021 11:54:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C1D306EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1625561665; bh=2bxcyMnKu3SewxitS9w+51BAhYXyh535o7NeOHeqC3o=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=p9IBfYHLPNGONAibF6yzcD2M9cHqm+DVQQX+oLvrRNZgLYVWdKG3l9kJNf7r1nFn4 OeNM6j50kQCh1gKOVvofz9aUQvidF7QoDcc3O7myhRWIDzDBN/nKlwTp+MYxyGoSqA GzkF1hWB22eMvPq0BNCQlbVjZTQ6ZERfbuw4AKB4= Received: from smtp29.i.mail.ru (smtp29.i.mail.ru [94.100.177.89]) (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 22FED6EC40 for ; Tue, 6 Jul 2021 11:54:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 22FED6EC40 Received: by smtp29.i.mail.ru with esmtpa (envelope-from ) id 1m0gqT-0003xn-Qd; Tue, 06 Jul 2021 11:54:22 +0300 To: Vladislav Shpilevoy , tarantool-patches@dev.tarantool.org, yaroslav.dynnikov@tarantool.org References: <6d8c2a728366edf5b0d208aeed9e027f870aa699.1625177222.git.v.shpilevoy@tarantool.org> <900c73e7-9824-ad3c-88f8-aa07b0382986@tarantool.org> <07f4dc34-0453-ce22-747e-6c50a2bcac12@tarantool.org> Message-ID: <7aa15d86-2ec9-c517-5553-e37f7370f49b@tarantool.org> Date: Tue, 6 Jul 2021 11:54:21 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <07f4dc34-0453-ce22-747e-6c50a2bcac12@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD954DFF1DC42D673FB4F75AC5594ACDC16869A51A860A12816182A05F53808504094DF542E3C8E3163F84C807BADED55C9749A95C2C41006E7B62E81ED1E55E807 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE731D82F3F177D3BCDEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063768D6DD405B71470F8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8497855E47E190D07F4115EF1D240B734117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC60CDF180582EB8FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751F2CC0D3CB04F14752D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EEC65AC60A1F0286FE9F804269016115C9D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE3FE4D9CDE3FF759CFC0837EA9F3D19764C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637BC468E7E89D8C5D6EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A57B2297C11F76F22AEC84E98E8A7449B8FF44CF29E352590ED59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75342909995EBBA6E4410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D348F9E8EBB46231487818F552F7EAFCA3AC5936A96C402477148F5486D6333902BB14B5FC81372414C1D7E09C32AA3244C9FD6B9AD4BCB609DA53491A702BFAF1FD9ADFF0C0BDB8D1FFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojotfFaHYUgbDkUuR1LAFk4w== X-Mailru-Sender: 583F1D7ACE8F49BD07526C4546A62CBFD0136FF44453CB8CC2DC972CAE48E3D54B7B9B07E2CAC9C323E75C7104EB1B885DEE61814008E47C7013064206BFB89F93956FB04BA385BE9437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH vshard 5/6] router: introduce automatic master discovery 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: Oleg Babin via Tarantool-patches Reply-To: Oleg Babin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thanks for your answers. Patch LGTM. I also asked Yaroslav and I hope he will take a look. On 05.07.2021 23:53, Vladislav Shpilevoy wrote: >>>>>    diff --git a/vshard/replicaset.lua b/vshard/replicaset.lua >>>>> index fa048c9..7747258 100644 >>>>> --- a/vshard/replicaset.lua >>>>> +++ b/vshard/replicaset.lua >>>>> @@ -345,18 +377,30 @@ local function replicaset_master_call(replicaset, func, args, opts) >>>>>        assert(opts == nil or type(opts) == 'table') >>>>>        assert(type(func) == 'string', 'function name') >>>>>        assert(args == nil or type(args) == 'table', 'function arguments') >>>>> -    local conn, err = replicaset_connect_master(replicaset) >>>>> -    if not conn then >>>>> -        return nil, err >>>>> -    end >>>>> -    if not opts then >>>>> -        opts = {timeout = replicaset.master.net_timeout} >>>>> -    elseif not opts.timeout then >>>>> -        opts = table.copy(opts) >>>>> -        opts.timeout = replicaset.master.net_timeout >>>>> +    local master = replicaset.master >>>>> +    if not master then >>>>> +        opts = opts and table.copy(opts) or {} >>>>> +        if opts.is_async then >>>>> +            return nil, lerror.vshard(lerror.code.MISSING_MASTER, >>>>> +                                      replicaset.uuid) >>>>> +        end >>>> Could / should we here wakeup master discovery if "auto" is specified? >>> We can. But I am afraid that under considerable RW requests load we >>> might wakeup it too often. And if there are many routers, they might >>> create a storm of `vshard.storage._call('info')` requests putting a >>> notable load on the storages. So I decided it is not safe until the >>> subscriptions are implemented. >> But we can't simply fail async requests when master is unknown. > There is not much of a choice for now. You will fail them even if the master > is here, but disconnected. Because netbox fails is_async immediately if the > connection is not in active nor in fetch_schema states. > > If it must be solved, I would better do it in a generic way for both > situations, separately. But it is not trivial. Because you start getting a > concept of is_async + timeout so as the requests wouldn't hang there for too > long time overflowing the queue of them. This means you would need a heap of > requests sorted by their deadlines, and you would flush them in on_connect > trigger, which AFAIR not suitable for making calls somewhy which is a next > issue (but I might be wrong). > > I wouldn't want to do that all in scope of master discovery ticket. Yes, I agree. I know about error in case when netbox is not connected. Ok. Let's it work in the same way as netbox async call. > >> And we even don't have exposed replicaset_wait_connected/replicaset_wait_master >> >> to call it before master will be known. As result several seconds we will get failed requests. > I didn't expose them yet because I am very reluctant towards exposing > anything until there is an explicit request from a user. Don't want to > overload the API. > >> Also I saw TODO in test that "RO requests should be able to go to replicas" and I expect questions >> >> about RTO 0 on read requests from our customers. > What do you mean as "RTO 0 on read requests"? > We faced it when developed CRUD module. To perform requests we need to know space schema. But all remote schema changes are visible only after request that triggers schema refetch. And we had working cluster but the first portion of requests failed because of outdated schema. Will we have something similar when we doesn't discover master yet but have replicas and our read requests will fail? If it's so please file at least an issue to fix it. Considering definition itself RTO means "recovery time objective". >> I don't know will this feature be used by cartridge but it could create small inconvenience for our customers >> >> in test because they should inject timeouts until master will be discovered (it's too artifical example but there were >> >> some similar questions when discovery started to work by chunks). >>>>>> +local function locate_masters(replicasets) >>>>> +    local is_all_done = true >>>>> +    local is_all_nop = true >>>>> +    local last_err >>>>> +    for _, replicaset in pairs(replicasets) do >>>>> +        local is_done, is_nop, err = replicaset_locate_master(replicaset) >>>> I think we should log result of master discovery. Especially if error occurred. >>> It is logged by the caller. See master_search_f(), init.lua:1067. >> Hmm... Yes, but I think such approach with last_err could lose some errors. > Yes, that is also done on purpose. I don't want to clog the logs with too > many errors. For instance, imagine you have 100 replicasets with 3 nodes in > each, each is polled with 0.5s. And there is no network. Then it can produce > about 600 errors per second. I tried to make the clogging less severe by showing > only the last error. And the idea is that you fix these errors one by one until > the log has no errors and discovery works fine. > > For example, firstly you fix the network if none of the futures was created. Then > you fix storage.call('info') being not existing due to the old version, and etc. > In the log you will see the next error to fix. > > I also wanted not to log the same error too often. For example, check that the > message didn't change in the master search fiber, and log it only on change > or once per, say, 10 seconds. But decided to wait if it explodes anywhere before > I complicate the code even more. > > Do you think it is not needed? I am not sure, and can switch to logging of > everything. Yes, sounds reasonable. Feel free to ignore following thoughts I just try to say my idea. t's not good to spam logs with error. But maybe we could aggregate error messages and print after each step. I mean e.g. we have a step where we call `pcall(conn.call, conn, func, args, async_opts)` we can save uris or uuids of bad hosts and print them in single message. >>>>> diff --git a/vshard/router/init.lua b/vshard/router/init.lua >>>>> index 5e2a96b..9407ccd 100644 >>>>> --- a/vshard/router/init.lua >>>>> +++ b/vshard/router/init.lua >>>>> @@ -1030,6 +1032,93 @@ local function failover_f(router) >>> <...> >>> >>>>> +-- >>>>> +-- Master discovery background function. It is supposed to notice master changes >>>>> +-- and find new masters in the replicasets, which are configured for that. >>>>> +-- >>>>> +-- XXX: due to polling the search might notice master change not right when it >>>> Is this TODO related tohttps://github.com/tarantool/vshard/issues/284  ? >>> Yes, that is one of the "solutions", although I would rather call it a crutch. >>> I prefer to fix it by doing fair subscriptions. And for that I at least need a >>> way to get netbox call result asynchronously, without having to call wait_result() >>> anywhere. >> Does it request some changes in netbox/iproto? I mean https://github.com/tarantool/tarantool/issues/6107 > 6107 is not about the protocol changes. It is only about > the interface on the server and in netbox. For vshard it > would be enough to patch netbox. I want to be able to do > something like that: > > local subscribe_complete > > local function subscribe_push(conn, msg) > log.info('Push: %s', msg) > -- ... > end > > local function subscribe_start(conn) > conn:call('subscribe', { > is_async = true, > on_complete = subscribe_complete, > on_complete_ctx = conn, > on_push = subscribe_push, > on_push_ctx = conn, > }) > end > > local function subscribe_complete(conn, res) > log.info('Subscription is done: %s, retry', res) > -- ... > subscribe_start(conn) > end > > subscribe_start(conn) > > 'Subscribe' in vshard would be a function on the storage > which returns when the storage's state changes anyhow. I could > manage these subscriptions on the client in a very cheap way > without fibers. Then I could make multiple subscriptions or > one big sub for all storage's details. Wouldn't matter. And > wouldn't cost almost anything on the storage too if 6107 > would be done. I did something similar for one project. "subscribe" reads from special channel and performs box.session.push(). Ok, I hope it will be done later.