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 D9E9C6F852; Mon, 15 Nov 2021 09:52:01 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D9E9C6F852 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1636959122; bh=3i3zZap5h4+l5i/UgimF4Wu6S9o1lLjO8lL01a/8PW4=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=kcmJ9Rv5QVWBSJ5YAw6ATUjGUzBEIQhITZXY9Y41R6YwWOTJv/DAy62hw2rTwOK29 sJVKoDqIJT1DNjIRmKp+WbPk947RnYgkY34sVpF8jkIN1JaD0CWkty6Xyou5IXgKVc JN9cntmFmORTCm6/Vn5TcTE7fqRXuf+g0LvvFZ2Y= Received: from smtp36.i.mail.ru (smtp36.i.mail.ru [94.100.177.96]) (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 A3C926F852 for ; Mon, 15 Nov 2021 09:51:59 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A3C926F852 Received: by smtp36.i.mail.ru with esmtpa (envelope-from ) id 1mmVqQ-0006P5-SE; Mon, 15 Nov 2021 09:51:59 +0300 Message-ID: <76dcc21e-0518-b5ef-4b10-e7c8578e505a@tarantool.org> Date: Mon, 15 Nov 2021 09:51:58 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Content-Language: en-GB To: Vladislav Shpilevoy , tarantool-patches@dev.tarantool.org References: <225fd821-26be-3afb-3ec5-c0b33487c5a1@tarantool.org> In-Reply-To: <225fd821-26be-3afb-3ec5-c0b33487c5a1@tarantool.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9731B3922EC063979C43A6585748E9610BDC1ABCFD86A591900894C459B0CD1B963E90E9F8F3C0D3EDE26238DEE73CF6481E1E706C83FD6892761160D39042EC4 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7051A6EFB787CE9C4EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006376EC5B14D896A2D978638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8BC68867BB64C8ED23F1E393A9FEC6789117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC974A882099E279BDA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352026055571C92BF10F618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE4B6963042765DA4BE21AE983DBD7FFC1D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE3A7DFDF579AB090EF2D242C3BD2E3F4C6C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637B8F435DEDE9E76EBEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A52DB3B2AF4CC866526677C8D5018DCC49EC4AF932FE1F19FFD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7536C62C4FBC402878410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34F38194B2C99DC12835A3BFCC87CD7E7F6CE27D45742EAC55946D4AAC07775A18A778AF5BB54429D61D7E09C32AA3244CC33D47464C7E5AEF704458842A27E177F522A1CF68F4BE05729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojjLiSo6osCe59YtkGoGtu+A== X-Mailru-Sender: 11C2EC085EDE56FA38FD4C59F7EFE40762698DC24B8D9FFAB7CCAB7B513032C22A0E4F39E0275F476BB2E709EA627F343C7DDD459B58856F0E45BC603594F5A135B915D4279FF0579437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2 10/11] box: enrich ER_READONLY with new details 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: Serge Petrenko via Tarantool-patches Reply-To: Serge Petrenko Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 13.11.2021 02:24, Vladislav Shpilevoy пишет: > Hi! Thanks for the review! > >> 12.11.2021 02:54, Vladislav Shpilevoy пишет: >>> ER_READONLY used not to have any details about the exact reason >>> why the instance is read-only. The patch changes that by adding >>> new fields into the error which explain why the error happened and >>> even help to avoid it for next requests. >>> >> Thanks for the changes! >> >> Please, find two comments below. >> >> Sorry for coming up late with this one, but I think it'd be good >> to report ro reason in box.info. Maybe box.info.ro_reason or >> something similar. Only when box.info.ro is true, of course. >> >> Otherwise we help the user only partially. He sees what's wrong when receives >> an error, but has to check every parameter manually when checks box.info.ro > Sounds useful, I added it in a new commit on top of the branch. See a new > email in the same thread. > >>> diff --git a/src/box/box.cc b/src/box/box.cc >>> index 1ed1ce3f8..323982969 100644 >>> --- a/src/box/box.cc >>> +++ b/src/box/box.cc >>> @@ -177,16 +177,54 @@ box_update_ro_summary(void) >>>   static int >>>   box_check_writable(void) >>>   { >>> -    if (is_ro_summary) { >>> +    if (!is_ro_summary) >>> +        return 0; >>> +    struct error *e = diag_set(ClientError, ER_READONLY); >>> +    struct raft *raft = box_raft(); >>> +    /* >>> +     * In case of multiple reasons at the same time only one is reported. >>> +     * But the order is important. For example, if the instance has election >>> +     * enabled, for the client it is better to see that it is a 'follower' >>> +     * and who is the leader than just see cfg 'read_only' is true. >>> +     */ >>> +    if (raft_is_ro(raft)) { >>> +        error_set_str(e, "reason", "election"); >>> +        error_set_str(e, "state", raft_state_str(raft->state)); >>> +        error_set_uint(e, "term", raft->volatile_term); >>> +        uint32_t id = raft->leader; >>> +        if (id != REPLICA_ID_NIL) { >>> +            error_set_uint(e, "leader_id", id); >>> +            struct replica *r = replica_by_id(id); >>> +            /* >>> +             * XXX: when the leader is dropped from _cluster, it >>> +             * is not reported to Raft. >>> +             */ >>> +            if (r != NULL) >>> +                error_set_uuid(e, "leader_uuid", &r->uuid); >>> +        } >>> +    } else if (txn_limbo_is_ro(&txn_limbo)) { >>> +        error_set_str(e, "reason", "synchro"); >>> +        uint32_t id = txn_limbo.owner_id; >>> +        error_set_uint(e, "queue_owner_id", id); >>> +        error_set_uint(e, "term", raft->volatile_term); >> I just noticed, we should report txn_limbo_greatest_term here, probably. >> >> This instance (which received ER_READONLY) is the leader, but hasn't claimed >> the limbo yet. >> This only makes sense when limbo term is behind raft's one. > Hmm, you are probably right. Thanks for noticing! Fixed in the > previous commit. > > ==================== > @@ -214,7 +214,7 @@ box_check_writable(void) > } else if (txn_limbo_is_ro(&txn_limbo)) { > error_set_str(e, "reason", "synchro"); > uint32_t id = txn_limbo.owner_id; > - uint64_t term = raft->volatile_term; > + uint64_t term = txn_limbo.promote_greatest_term; > error_set_uint(e, "queue_owner_id", id); > error_set_uint(e, "term", term); > ==================== Thanks for the changes! One final note: I propose to move box_ro_reason() from the last commit here and use it when setting error reason, so that error.reason would be the same as box.info.ro_reason. LGTM otherwise. -- Serge Petrenko