From: Vladislav Shpilevoy via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Serge Petrenko <sergepetrenko@tarantool.org>, tarantool-patches@dev.tarantool.org, vdavydov@tarantool.org Subject: Re: [Tarantool-patches] [PATCH 9/9] box: enrich ER_READONLY with new details Date: Fri, 12 Nov 2021 00:52:36 +0100 [thread overview] Message-ID: <1b90fe62-976a-0003-4c9d-06e421acec7b@tarantool.org> (raw) In-Reply-To: <2af7c607-01a1-7060-4ecd-fe9f526c8c07@tarantool.org> 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: <box.info.election.state of this instance>, >> + leader_id: <box.info.id of the leader>, >> + leader_uuid: <box.info.uuid of the leader>, >> + reason: election, >> + term: <box.info.election.term of this instance> >> + } >> + ``` > > 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: <box.info.election.term of this instance> } - ``` \ 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) ====================
next prev parent reply other threads:[~2021-11-11 23:52 UTC|newest] Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-05 23:56 [Tarantool-patches] [PATCH 0/9] ER_READONLY reason Vladislav Shpilevoy via Tarantool-patches 2021-11-05 23:56 ` [Tarantool-patches] [PATCH 1/9] diag: return created error from diag_set() Vladislav Shpilevoy via Tarantool-patches 2021-11-05 23:56 ` [Tarantool-patches] [PATCH 2/9] error: introduce error_payload Vladislav Shpilevoy via Tarantool-patches 2021-11-08 15:14 ` Serge Petrenko via Tarantool-patches 2021-11-11 23:50 ` Vladislav Shpilevoy via Tarantool-patches 2021-11-12 6:29 ` Serge Petrenko via Tarantool-patches 2021-11-05 23:56 ` [Tarantool-patches] [PATCH 3/9] error: move code to struct error from ClientError Vladislav Shpilevoy via Tarantool-patches 2021-11-08 15:15 ` Serge Petrenko via Tarantool-patches 2021-11-11 23:50 ` Vladislav Shpilevoy via Tarantool-patches 2021-11-12 6:31 ` Serge Petrenko via Tarantool-patches 2021-11-05 23:56 ` [Tarantool-patches] [PATCH 4/9] error: use error_payload to store optional members Vladislav Shpilevoy via Tarantool-patches 2021-11-05 23:56 ` [Tarantool-patches] [PATCH 5/9] error: use error_payload in MessagePack codecs Vladislav Shpilevoy via Tarantool-patches 2021-11-05 23:56 ` [Tarantool-patches] [PATCH 6/9] error: use error_payload in Lua Vladislav Shpilevoy via Tarantool-patches 2021-11-05 23:56 ` [Tarantool-patches] [PATCH 7/9] luatest: copy config in cluster:build_server() Vladislav Shpilevoy via Tarantool-patches 2021-11-05 23:56 ` [Tarantool-patches] [PATCH 8/9] luatest: add new helpers for 'server' object Vladislav Shpilevoy via Tarantool-patches 2021-11-08 15:16 ` Serge Petrenko via Tarantool-patches 2021-11-11 23:51 ` Vladislav Shpilevoy via Tarantool-patches 2021-11-05 23:56 ` [Tarantool-patches] [PATCH 9/9] box: enrich ER_READONLY with new details Vladislav Shpilevoy via Tarantool-patches 2021-11-06 19:30 ` Cyrill Gorcunov via Tarantool-patches 2021-11-07 16:45 ` Vladislav Shpilevoy via Tarantool-patches 2021-11-07 20:19 ` Cyrill Gorcunov via Tarantool-patches 2021-11-08 15:18 ` Serge Petrenko via Tarantool-patches 2021-11-11 23:52 ` Vladislav Shpilevoy via Tarantool-patches [this message] 2021-11-08 14:25 ` [Tarantool-patches] [PATCH 0/9] ER_READONLY reason Vladimir Davydov via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1b90fe62-976a-0003-4c9d-06e421acec7b@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=sergepetrenko@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --cc=vdavydov@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 9/9] box: enrich ER_READONLY with new details' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox