From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp52.i.mail.ru (smtp52.i.mail.ru [94.100.177.112]) (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 4461D4696C3 for ; Mon, 27 Apr 2020 15:22:37 +0300 (MSK) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) From: Serge Petrenko In-Reply-To: <20200424163945.GD27619@atlas> Date: Mon, 27 Apr 2020 15:22:36 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: References: <20200424162855.25920-1-sergepetrenko@tarantool.org> <20200424163945.GD27619@atlas> Subject: Re: [Tarantool-patches] [PATCH v2] replication: add box.info.replication_anon List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Konstantin Osipov Cc: tarantool-patches@dev.tarantool.org, Vladislav Shpilevoy > 24 =D0=B0=D0=BF=D1=80. 2020 =D0=B3., =D0=B2 19:39, Konstantin Osipov = =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0=B0= ): >=20 > * Serge Petrenko [20/04/24 19:33]: >> Closes #4900 >>=20 >> @TarantoolBot document >> Title: add new field to box.info: replication_anon >>=20 >> 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. >>=20 >> Example: >> ``` >> tarantool> box.info.replication_anon >> --- >> - [] >> ... >>=20 >> tarantool> box.info.replication_anon() >=20 > Why do you have to use ()? Isn't it inconsistent with > box.info.replication? >=20 It=E2=80=99s done in order to shorten `box.info` output. There may be = lots of anonymous replicas following a master. I=E2=80=99ve 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); =20 + lua_pushliteral(L, "count"); + lua_pushinteger(L, replicaset.anon_count); + lua_settable(L, -3); + lua_newtable(L); /* metatable */ =20 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 =3D *replica_uuid; replica_hash_insert(&replicaset.hash, replica); replica->anon =3D true; + replicaset.anon_count++; return replica; } =20 @@ -909,6 +910,8 @@ replica_on_relay_stop(struct replica *replica) * replicas. */ assert(replica->applier =3D=3D 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() | --- >=20 > --=20 > Konstantin Osipov, Moscow, Russia > https://scylladb.com -- Serge Petrenko sergepetrenko@tarantool.org