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 B9D8E6EC5B; Thu, 13 May 2021 23:24:16 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B9D8E6EC5B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1620937456; bh=Do0n/GmeuZrSIsOhFaWYxnd6qO1TbUFKyncabU3S9UU=; 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=fatAWxM+GreBDbaLZXXR8OYJ5HPiAX1K1S3fHzBOvIhpJZBOyDXmwQMY4UqL6mt5m TcETDnI5LFub9j3V4HYhcUcu8piPWhTC7zBnsxxmTmW1ZTkN50xVJ2xDGrki/VUM8E fDc8v/tXvHLkEtKCdOQvjwcbkVxXOt2QuGaM8uCw= Received: from smtp50.i.mail.ru (smtp50.i.mail.ru [94.100.177.110]) (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 A35936EC5B for ; Thu, 13 May 2021 23:23:30 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A35936EC5B Received: by smtp50.i.mail.ru with esmtpa (envelope-from ) id 1lhHrl-0002wF-9X; Thu, 13 May 2021 23:23:30 +0300 To: Vladislav Shpilevoy , tarantool-patches@dev.tarantool.org, yaroslav.dynnikov@tarantool.org References: <04d7d05f09a5ee7ed52b27c480e81232c406e415.1620903962.git.v.shpilevoy@tarantool.org> Message-ID: <00948536-25b1-dcf2-abc7-6e22d9a683e2@tarantool.org> Date: Thu, 13 May 2021 23:23:26 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <04d7d05f09a5ee7ed52b27c480e81232c406e415.1620903962.git.v.shpilevoy@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD95978C26455E69BE0BB6090B4F8997C21AA3492AFA30115D5182A05F5380850404D50FDC0003D202C5407E13EB80890EC562A7379952455504955782FCE9142A0 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7F65C230EDDCD559EEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637E1D2769089B3DFB28638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D86B2909E07354D6D503C286CC02716C5C117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC5FC25ED3FCEC3375A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352026055571C92BF10F28451B159A507268D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EEB28585415E75ADA9269E641683F5DD3FD8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE3A816C540FC8EEC30C0837EA9F3D19764C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637E2D9485159F398E1EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2368A440D3B0F6089093C9A16E5BC824A2A04A2ABAA09D25379311020FFC8D4ADED1450B5CB7B51894D9345CDA97A576B X-C1DE0DAB: 0D63561A33F958A5D1EDC60F3FA690A8719206B357A08CFD6B20FBD55A79A7BCD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75F04B387B5D7535DE410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D349DAEDEF7DE8FDCFAE5CCBF4C7F57334445A45B858AC7158D56092744C4C6EDA4E1E77ED38727CB8A1D7E09C32AA3244CA8F6E71DC98EBEA385F94EFBDF2AD15330452B15D76AEC14FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojoybArHp+PQURqqm0GdysFA== X-Mailru-Sender: 9482C2B233321BD21A641ECFDAC686C8A22AE6A6DA8E084E5407E13EB80890EC8FF8BC079CCEBBDC7019711D9D5B048E1458020726E2BC9FD5ECBA0B92C0A936CDC7563AA7CEBD287402F9BA4338D657ED14614B50AE0675 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 2/2] vshard: fix buckets_count() on replicas 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" Hi! Thanks for your patch! Three comments below. On 13.05.2021 14:07, Vladislav Shpilevoy wrote: > +local function schema_install_triggers() > + local _bucket = box.space._bucket > + if M.bucket_on_replace then > + local ok, err = pcall(_bucket.on_replace, _bucket, nil, > + M.bucket_on_replace) > + if not ok then > + log.warn('Could not drop old trigger from '.. > + '_bucket: %s', err) > + end > + end > + _bucket:on_replace(bucket_generation_increment) > + M.bucket_on_replace = bucket_generation_increment > +end > + > +local function schema_install_on_replace(_, new) > + -- Wait not just for _bucket to appear, but for the entire > + -- schema. This might be important if the schema will ever > + -- consist of more than just _bucket. > + if new[1] ~= 'vshard_version' then Is it possible that someone drops something from _schema space? I mean that in such case new will be nil. I could provide one such case - when user needs to execute box.once once again, (s)he drops corresponding record from _schema space. > + return > + end > + schema_install_triggers() > + > + local _schema = box.space._schema nit: you could get it from the third argument of the trigger. But up to you. > + local ok, err = pcall(_schema.on_replace, _schema, nil, M.schema_on_replace) > + if not ok then > + log.warn('Could not drop trigger from _schema inside of the '.. > + 'trigger: %s', err) > + end > + M.schema_on_replace = nil > + -- Drop the caches which might have been created while the > + -- schema was being replicated. > + bucket_generation_increment() > +end > + > +-- > +-- Install the triggers later when there is an actual schema to install them on. > +-- On replicas it might happen that they are vshard-configured earlier than the > +-- master and therefore don't have the schema right away. > +-- > +local function schema_install_triggers_delayed() > + log.info('Could not find _bucket space to install triggers - delayed '.. > + 'until the schema is replicated') > + assert(not box.space._bucket) > + local _schema = box.space._schema > + if M.schema_on_replace then > + local ok, err = pcall(_schema.on_replace, _schema, nil, > + M.schema_on_replace) > + if not ok then > + log.warn('Could not drop trigger from _schema: %s', err) > + end > + end > + _schema:on_replace(schema_install_on_replace) > + M.schema_on_replace = schema_install_on_replace > +end > + > -- VShard versioning works in 4 numbers: major, minor, patch, and > -- a last helper number incremented on every schema change, if > -- first 3 numbers stay not changed. That happens when users take > @@ -2612,17 +2676,15 @@ local function storage_cfg(cfg, this_replica_uuid, is_reload) > local uri = luri.parse(this_replica.uri) > schema_upgrade(is_master, uri.login, uri.password) > > - if M.bucket_on_replace then > - box.space._bucket:on_replace(nil, M.bucket_on_replace) > - M.bucket_on_replace = nil > - end > - lref.cfg() > - if is_master then > - box.space._bucket:on_replace(bucket_generation_increment) > - M.bucket_on_replace = bucket_generation_increment > + if is_master or box.space._bucket then Is it possible that "is_master" is true and _bucket is nil? Why simple `if box.space._bucket` is not enough?