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 6B2CF6F853; Sat, 13 Nov 2021 02:24:41 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6B2CF6F853 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1636759481; bh=LyhMZOu9QLVF9dT9MVjgd5BUoGabFoGwl0pZRbklSnY=; 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=dldjwnFHyYgzAvZBH/VZpvlTayhqjtaXabJGHC9NfeVxUiG75K94RsOTLCD66y2Mr RbaGGH/e3z7N4NRyYuIugIRX0C0YaoijwbHnih6Do5HWAhkKBI5JFbYeJJR0zSgJvU Qlkaxic0zbQqDQVeChVWE4gO+WnvEDqFeEPTfFrM= 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 1AD686F853 for ; Sat, 13 Nov 2021 02:24:40 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1AD686F853 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1mlfuR-00028u-8z; Sat, 13 Nov 2021 02:24:39 +0300 Message-ID: <225fd821-26be-3afb-3ec5-c0b33487c5a1@tarantool.org> Date: Sat, 13 Nov 2021 00:24:38 +0100 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-US To: Serge Petrenko , tarantool-patches@dev.tarantool.org References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9731B3922EC06397990E8B89D97A64D716CAA5505BE500FF700894C459B0CD1B914ED1B61F47237AD037A5B38AEB4F195FAD2CB537C7C45AAD6626D2099F7E75E X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE77AA33865E80AF043EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006370F98874192B1BA168638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D83F1E1ED56FE40340D20F83B01506923B117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC8C7ADC89C2F0B2A5A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751FBDFBBEFFF4125B51D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6B1CFA6D474D4A6A4089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B50544ABBB58A88CF8DFEB1462545D66570C X-C1DE0DAB: 0D63561A33F958A53BE482C870B35F4A42A5DBA1F396FF7D4299FB1EB5D93A40D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA754E2A133C74F7AB4F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D341ADA1A41A420E9B234BEDA4ABCAD6BAD2154D62BA3B06B97E4500B59889EBC6F643D1B6F5261A2701D7E09C32AA3244CDF69BB026FFECFFD2F967A00886317E88580396430872480729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojLk+X/GdHsnqoO/OnVxRn4g== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D2EF007778F751E3745E32E011857B7463841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B 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: 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! > 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); ====================