From: Serge Petrenko <sergepetrenko@tarantool.org> To: v.shpilevoy@tarantool.org, gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH] replication: list anonymous replicas in box.info.replication Date: Thu, 23 Apr 2020 16:01:54 +0300 [thread overview] Message-ID: <20200423130154.23910-1-sergepetrenko@tarantool.org> (raw) Closes #4900 @TarantoolBot document Title: Enrich box.info.replication output with anonymous replicas A new field is added to replica info in `box.info.replication` output: `anon`. The field is boolean and set to `true` for anonymous replicas and to `false` for normal replicas. Also now anonymous replicas are listed in `box.info.replication` together with normal ones, so it's easier to track their connection state. Anonymous replicas occupy table slots past the biggest-id normal replica. Example: ``` ... replication: 1: id: 1 uuid: 326eb713-1b79-4b43-9b48-661314260c61 lsn: 4 anon: false 2: id: 0 uuid: 869aa6d8-7e78-488c-945d-ff5ef8cf8a42 lsn: 0 downstream: status: follow idle: 0.4463420000011 vclock: {1: 4} anon: true ... ``` Note, that anonymous replicas hide their lsn from the others, so anonymous replica lsn will always be reported as zero, even if anonymous replicas perform some local space operations. To know the anonymous replica's lsn, you have to issue `box.info.lsn` on it. --- https://github.com/tarantool/tarantool/issues/4900 https://github.com/tarantool/tarantool/tree/sp/gh-4900-list-anon-replicas @ChangeLog - Start listing anonymous replicas in `box.info.replication` and add `anon` field to each replica output. Anonymous replicas are listed after all the normal replicas. (gh-4900) src/box/lua/info.c | 20 ++++++++++++++++++++ test/replication/anon.result | 12 ++++++++++-- test/replication/anon.test.lua | 4 +++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/box/lua/info.c b/src/box/lua/info.c index a789f7822..5c07c91a9 100644 --- a/src/box/lua/info.c +++ b/src/box/lua/info.c @@ -169,6 +169,10 @@ lbox_pushreplica(lua_State *L, struct replica *replica) lua_pushinteger(L, replica->id); lua_settable(L, -3); + lua_pushstring(L, "anon"); + lua_pushboolean(L, replica->anon); + lua_settable(L, -3); + lua_pushstring(L, "uuid"); lua_pushstring(L, tt_uuid_str(&replica->uuid)); lua_settable(L, -3); @@ -201,6 +205,11 @@ lbox_info_replication(struct lua_State *L) lua_setfield(L, -2, "__serialize"); lua_setmetatable(L, -2); + /* + * A counter to start enumerating anonymous replicas after + * all the other ones. + */ + uint32_t max_id = 0; replicaset_foreach(replica) { /* Applier hasn't received replica id yet */ if (replica->id == REPLICA_ID_NIL) @@ -209,6 +218,17 @@ lbox_info_replication(struct lua_State *L) lbox_pushreplica(L, replica); lua_rawseti(L, -2, replica->id); + if (replica->id > max_id) + max_id = replica->id; + } + + replicaset_foreach(replica) { + if (!replica->anon) + continue; + + lbox_pushreplica(L, replica); + + lua_rawseti(L, -2, ++max_id); } return 1; diff --git a/test/replication/anon.result b/test/replication/anon.result index cbbeeef09..6f907f614 100644 --- a/test/replication/anon.result +++ b/test/replication/anon.result @@ -151,10 +151,18 @@ test_run:cmd('switch default') | - true | ... --- Replica isn't visible on master. +-- Anonymous replicas are shown in master's box.info.replication. #box.info.replication | --- - | - 1 + | - 2 + | ... +box.info.replication[2].anon + | --- + | - true + | ... +box.info.replication[2].downstream.status + | --- + | - follow | ... -- Test that replication (even anonymous) from an anonymous diff --git a/test/replication/anon.test.lua b/test/replication/anon.test.lua index 627dc5c8e..3a6756342 100644 --- a/test/replication/anon.test.lua +++ b/test/replication/anon.test.lua @@ -50,8 +50,10 @@ box.space.loc:truncate() test_run:cmd('switch default') --- Replica isn't visible on master. +-- Anonymous replicas are shown in master's box.info.replication. #box.info.replication +box.info.replication[2].anon +box.info.replication[2].downstream.status -- Test that replication (even anonymous) from an anonymous -- instance is forbidden. An anonymous replica will fetch -- 2.21.1 (Apple Git-122.3)
next reply other threads:[~2020-04-23 13:02 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-23 13:01 Serge Petrenko [this message] 2020-04-23 14:06 ` Konstantin Osipov
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=20200423130154.23910-1-sergepetrenko@tarantool.org \ --to=sergepetrenko@tarantool.org \ --cc=gorcunov@gmail.com \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH] replication: list anonymous replicas in box.info.replication' \ /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