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 277676FC82; Fri, 12 Nov 2021 02:52:41 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 277676FC82 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1636674761; bh=wOTyH/hek5q6DqBY2L9fJeNZwS07UQbo/qKv0Ta4R3U=; 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=LjyAzB1Sk23wPkeEkwhgypQcwoeQCjxMY9IIsZJKB0RDSu4Hsm5jA6ZxzcUs2HlfB AtjxEBE8FJpgdMJvebSMJrpsQovZhJoUjQhdMx4Dj6Qtnpw37GX4HDBiAsmh/K61hK 9cV0rlXIRA5lCbTJHFrel7modTR0OORo2GJf5tlg= 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 3FEAA6FC82 for ; Fri, 12 Nov 2021 02:52:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3FEAA6FC82 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1mlJrx-0005e9-4C; Fri, 12 Nov 2021 02:52:37 +0300 Message-ID: <1b90fe62-976a-0003-4c9d-06e421acec7b@tarantool.org> Date: Fri, 12 Nov 2021 00:52:36 +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 To: Serge Petrenko , tarantool-patches@dev.tarantool.org, vdavydov@tarantool.org References: <99799340f06652929897e363e42a5227d12277a1.1636156453.git.v.shpilevoy@tarantool.org> <2af7c607-01a1-7060-4ecd-fe9f526c8c07@tarantool.org> Content-Language: en-US In-Reply-To: <2af7c607-01a1-7060-4ecd-fe9f526c8c07@tarantool.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9731B3922EC063979C43A6585748E9610BDC1ABCFD86A591900894C459B0CD1B90A07E5D9CA5D6CA19C18E02C48A0AAF97F76FE7EF67E38FF11835EED5C149C5A X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7A179494B5629353BEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637E149C29A36E092738638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8F1EEDD9D558B57BE07A282DF7A45B954117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8BAA867293B0326636D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6300D3B61E77C8D3B089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B50537BF44C8E1EC058A3A8FCD720D219843 X-C1DE0DAB: 0D63561A33F958A56F4EB9CC76E59BCBAA97645D1FA0B94B00B4E8C65D7E1E1ED59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7536C62C4FBC402878410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34D95739AEDB3821B41B2031A15F660FA7B1E1F1F5B32009A364268200CA69C2DDB7BEB3620E5A48AE1D7E09C32AA3244C65F2CC1A91024F2C1B0702D985C899B395A9E0DC41E9A4CFFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj4t8MBgWr8bI75HcMaAm5ig== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DF5BFFD066CC2EFDB955D9C16479B460D3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 9/9] 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" Thanks for the review! >> diff --git a/changelogs/unreleased/gh-5568-readonly-reason.md b/changelogs/unreleased/gh-5568-readonly-reason.md >> new file mode 100644 >> index 000000000..f90b53bdf >> --- /dev/null >> +++ b/changelogs/unreleased/gh-5568-readonly-reason.md >> @@ -0,0 +1,24 @@ >> +## feature/core >> + >> +* Error objects with the code `box.error.READONLY` now have additional fields >> +  explaining why the error happened (gh-5568). >> + >> +  For instance, if the error was due to `box.cfg{read_only = true}`, then the >> +  error will have fields: >> +  ``` >> +  { >> +    reason = 'state', >> +    state = 'read_only' >> +  } >> +  ``` >> +  Or if it was due to not being a leader with `box.cfg{election_mode = ...}` set >> +  not to `off`, then: >> +  ``` >> +  { >> +    state: , >> +    leader_id: , >> +    leader_uuid: , >> +    reason: election, >> +    term: >> +  } >> +  ``` > > 1. Let's duplicate the additional error information in the error message. > >    If it's hard to log every field, let's at least encode reason and state, >    so that the user knows what's wrong by simply looking at the error message. I added this in a new commit on top of the branch. >> \ No newline at end of file I forgot a new line, added one: ==================== @@ -21,4 +21,4 @@ reason: election, term: } - ``` \ No newline at end of file + ``` ==================== >> diff --git a/test/replication-luatest/gh_5568_read_only_reason_test.lua b/test/replication-luatest/gh_5568_read_only_reason_test.lua >> new file mode 100644 >> index 000000000..d4f7ff957 >> --- /dev/null >> +++ b/test/replication-luatest/gh_5568_read_only_reason_test.lua <...> >> + >> +-- >> +-- Read-only because does not own the limbo. Knows the owner. >> +-- >> +g.test_read_only_reason_synchro = function(g) >> +    g.master:exec(function() >> +        box.schema.create_space('test', {is_sync = true}):create_index('pk') > > 2. The space creation isn't necessary for this test. Indeed, dropped: ==================== @@ -172,7 +172,6 @@ end -- g.test_read_only_reason_synchro = function(g) g.master:exec(function() - box.schema.create_space('test', {is_sync = true}):create_index('pk') box.ctl.promote() end) @@ -198,7 +197,6 @@ g.test_read_only_reason_synchro = function(g) -- Cleanup. g.master:exec(function() - box.space.test:drop() box.ctl.demote() end) end ==================== <...> >> + >> +    local ok, err = g.replica:exec(function() >> +        local ok, err = pcall(box.schema.create_space, 'test') >> +        return ok, err:unpack() >> +    end) >> +    t.assert(not ok, 'fail ddl') >> +    t.assert(err.term, 'has term') >> +    t.assert(not err.leader_uuid, 'has no leader uuid') >> +    t.assert_covers(err, { >> +        reason = 'election', >> +        state = 'follower', >> +        leader_id = leader_id, >> +        code = box.error.READONLY, >> +        type = 'ClientError' >> +    }, 'reason is election, has leader but no uuid') >> +end >> + >> +-- >> +-- Read-only because does not own the limbo. Knows the owner, but now its UUID. >> +-- > > 3. Typo: now -> not. Done: ==================== -- --- Read-only because does not own the limbo. Knows the owner, but now its UUID. +-- Read-only because does not own the limbo. Knows the owner, but not its UUID. -- g.test_read_only_reason_synchro_no_uuid = function(g) ====================