From: Serge Petrenko <sergepetrenko@tarantool.org> To: Konstantin Osipov <kostja.osipov@gmail.com> Cc: tarantool-patches@dev.tarantool.org, Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH v2] replication: add box.info.replication_anon Date: Mon, 27 Apr 2020 15:22:36 +0300 [thread overview] Message-ID: <EF811542-8711-481B-8F2C-95239E99E445@tarantool.org> (raw) In-Reply-To: <20200424163945.GD27619@atlas> > 24 апр. 2020 г., в 19:39, Konstantin Osipov <kostja.osipov@gmail.com> написал(а): > > * Serge Petrenko <sergepetrenko@tarantool.org> [20/04/24 19:33]: >> Closes #4900 >> >> @TarantoolBot document >> Title: add new field to box.info: replication_anon >> >> It is now possible to list all the anonymous replicas following the >> instance with a call to `box.info.replication_anon()` >> The output is similar to the one produced by `box.info.replication` with >> an exception that anonymous replicas are indexed by their uuid strings >> rather then server ids, since server ids have no meaning for anonymous >> replicas. >> >> Example: >> ``` >> tarantool> box.info.replication_anon >> --- >> - [] >> ... >> >> tarantool> box.info.replication_anon() > > Why do you have to use ()? Isn't it inconsistent with > box.info.replication? > It’s done in order to shorten `box.info` output. There may be lots of anonymous replicas following a master. I’ve updated the commit message correspondingly. It was also agreed verbally, that we should output the number of anonymous replicas following a master on `box.info.replication_anon` without the `()`. The diff is below. diff --git a/src/box/lua/info.c b/src/box/lua/info.c index c4f90bda1..e7318fcd1 100644 --- a/src/box/lua/info.c +++ b/src/box/lua/info.c @@ -248,6 +248,10 @@ lbox_info_replication_anon(struct lua_State *L) */ lua_newtable(L); + lua_pushliteral(L, "count"); + lua_pushinteger(L, replicaset.anon_count); + lua_settable(L, -3); + lua_newtable(L); /* metatable */ lua_pushstring(L, "__call"); diff --git a/src/box/replication.cc b/src/box/replication.cc index 7c10fb6f2..1b61c92c0 100644 --- a/src/box/replication.cc +++ b/src/box/replication.cc @@ -219,6 +219,7 @@ replicaset_add_anon(const struct tt_uuid *replica_uuid) replica->uuid = *replica_uuid; replica_hash_insert(&replicaset.hash, replica); replica->anon = true; + replicaset.anon_count++; return replica; } @@ -909,6 +910,8 @@ replica_on_relay_stop(struct replica *replica) * replicas. */ assert(replica->applier == NULL); + assert(replicaset.anon_count > 0); + replicaset.anon_count--; } } if (replica_is_orphan(replica)) { diff --git a/src/box/replication.h b/src/box/replication.h index 9df91e611..93a25c8a7 100644 --- a/src/box/replication.h +++ b/src/box/replication.h @@ -203,6 +203,8 @@ struct replicaset { * from a remote master. */ bool is_joining; + /* A number of anonymous replicas following this instance. */ + int anon_count; /** Applier state. */ struct { /** diff --git a/test/replication/anon.result b/test/replication/anon.result index f3f9c60ed..a7e244d3f 100644 --- a/test/replication/anon.result +++ b/test/replication/anon.result @@ -154,7 +154,7 @@ test_run:cmd('switch default') -- Test box.info.replication_anon. box.info.replication_anon | --- - | - [] + | - count: 1 | ... #box.info.replication_anon() | --- > > -- > Konstantin Osipov, Moscow, Russia > https://scylladb.com -- Serge Petrenko sergepetrenko@tarantool.org
next prev parent reply other threads:[~2020-04-27 12:22 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-24 16:28 Serge Petrenko 2020-04-24 16:39 ` Konstantin Osipov 2020-04-27 12:22 ` Serge Petrenko [this message] 2020-04-27 12:40 ` Konstantin Osipov 2020-05-01 19:56 ` Vladislav Shpilevoy 2020-05-07 11:17 ` Serge Petrenko 2020-05-10 19:52 ` Vladislav Shpilevoy 2020-05-15 14:16 ` Kirill Yukhin
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=EF811542-8711-481B-8F2C-95239E99E445@tarantool.org \ --to=sergepetrenko@tarantool.org \ --cc=kostja.osipov@gmail.com \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v2] replication: add box.info.replication_anon' \ /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