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 010686EC58; Wed, 26 May 2021 21:44:30 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 010686EC58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1622054670; bh=/bn4uvv5vIyihMQvhofWH5CR6DYe7rsOJM63WB4heQE=; 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=sNGdcpP/XpSaq1orIJTTj6MUa0hE8RL7fVKvnB2xwJdQ7njNYDLBBsR8BavvvAXki DteS2+X/HhQsqA/lZR/Sa6hGDjhAgglkZuHusDKKgWN9rW53HmS7tEVp0b2maXMvgf MuOnXAUyK/2CXzAoknUKvMm1SAdaj0ZJ+qfebqvA= 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 3AF306EC58 for ; Wed, 26 May 2021 21:44:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3AF306EC58 Received: by smtp29.i.mail.ru with esmtpa (envelope-from ) id 1llyW3-0003oT-6c; Wed, 26 May 2021 21:44:27 +0300 To: Oleg Babin , tarantool-patches@dev.tarantool.org, yaroslav.dynnikov@tarantool.org References: <8d7e89a4884559963c02719fca0dc0720632fc73.1621975324.git.v.shpilevoy@tarantool.org> <7284b714-dfa7-026e-5979-2d5eb3e55386@tarantool.org> Message-ID: <25369324-54cd-1611-c39a-0c4a1e8686a6@tarantool.org> Date: Wed, 26 May 2021 20:44:26 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: <7284b714-dfa7-026e-5979-2d5eb3e55386@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9157EECD0FDB90B9A5E1FB2BD85CDC5FA3FC9EA359F29112C00894C459B0CD1B9CAB8F55DB74D01AB5D908F5408CE2BC509BDA8693C08D262A938C1B4F21A4609 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7AEADB70076298E75EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006375045C080FAAE96148638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8173878A92A9621E4B02197E9E0A4FAF6117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC8C7ADC89C2F0B2A5A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EEC8105B04EFE076286136E347CC761E074AD6D5ED66289B52698AB9A7B718F8C46E0066C2D8992A16725E5C173C3A84C34046BBBC458D877CBA3038C0950A5D36B5C8C57E37DE458B0BC6067A898B09E46D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE7588D3C263EAE74EA731C566533BA786AA5CC5B56E945C8DA X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2368A440D3B0F6089093C9A16E5BC824A2A04A2ABAA09D25379311020FFC8D4ADF372762DF97D2D8EE343B7AC97C5348E X-C1DE0DAB: 0D63561A33F958A56F0F0918EF3FA190B119A90337EC1D9EF05C41F9B09504BED59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75E3127721F5A72C97410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D343DCFC3BEDFB0242D89909C3C1BCCB56D01852ABD6008108CE73AC9AC9A9B681DA023C1825A42832C1D7E09C32AA3244CF9070362CA3E4474F5807A2EA8B270F7A8CE788DE6831205FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojiWl9RlzdednA5xDVFs8HOw== X-Mailru-Sender: 504CC1E875BF3E7D9BC0E5172ADA3110AF5370EE6C4A7CCAA7B89E70F034E0325B78F42A239239D807784C02288277CA03E0582D3806FB6A5317862B1921BA260ED6CFD6382C13A6112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH vshard 1/1] rebalancer: give more info at bucket_recv() fail 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" Hi! Thanks for the review! >> diff --git a/vshard/storage/init.lua b/vshard/storage/init.lua >> index 63e0398..7045d91 100644 >> --- a/vshard/storage/init.lua >> +++ b/vshard/storage/init.lua >> @@ -1254,7 +1254,13 @@ local function bucket_recv_xc(bucket_id, from, data, opts) >>           end >>           box.begin() >>           for _, tuple in ipairs(space_data) do >> -            space:insert(tuple) >> +            local ok, err = pcall(space.insert, space, tuple) >> +            if not ok then >> +                box.rollback() > > Am I right that before a patch nobody rolled back transaction is case of error? > > How did it work? bucket_recv_xc() is called only from bucket_recv() via pcall. Bucket_recv() does the rollback. I have the _xc() version so as not to wrap into pcalls everything, and as a protection against potential OOM. For instance, when I create a table in there like `{bucket_id, recvg, from}` - it might fail too, AFAIU. >> +                return nil, lerror.vshard(lerror.code.BUCKET_RECV_DATA_ERROR, >> +                                          bucket_id, space.name, >> +                                          box.tuple.new(tuple), err) >> +            end > > Do you really need `box.tuple.new` here. Why just `tuple` is not enough? Because `tuple` is a Lua table. When formatted into %s in the error message, it turns into 'table 0x......' instead of showing the content, while tuple objects have a nice serializer. > AFAIU box.tuple.new doesn't just increment tuple ref-counter and construct new tuple. It does exactly this. > Rebalancing is quite CPU-intensive operation so I'm not sure that such behaviour doesn't > > make error case worse. I thought about it, but decided that it is not worth optimizing the error case. It is better to provide a good error message. I also thought about using json.encode() to avoid 'table 0x.....' problem, but decided I don't want to introduce a dependency on the entire json module just for this.