* [Tarantool-patches] [PATCH] replication: list anonymous replicas in box.info.replication
@ 2020-04-23 13:01 Serge Petrenko
2020-04-23 14:06 ` Konstantin Osipov
0 siblings, 1 reply; 2+ messages in thread
From: Serge Petrenko @ 2020-04-23 13:01 UTC (permalink / raw)
To: v.shpilevoy, gorcunov; +Cc: tarantool-patches
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)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Tarantool-patches] [PATCH] replication: list anonymous replicas in box.info.replication
2020-04-23 13:01 [Tarantool-patches] [PATCH] replication: list anonymous replicas in box.info.replication Serge Petrenko
@ 2020-04-23 14:06 ` Konstantin Osipov
0 siblings, 0 replies; 2+ messages in thread
From: Konstantin Osipov @ 2020-04-23 14:06 UTC (permalink / raw)
To: Serge Petrenko; +Cc: tarantool-patches, v.shpilevoy
* Serge Petrenko <sergepetrenko@tarantool.org> [20/04/23 16:05]:
> 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:
^^^^^^^ This is not an ordinal number, it's server id.
An anonymous replica doesn't have server id.
Why do you think assigning an unused id is a good idea? This will
break monitoring which may rely on server id being stable.
--
Konstantin Osipov, Moscow, Russia
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-23 14:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-23 13:01 [Tarantool-patches] [PATCH] replication: list anonymous replicas in box.info.replication Serge Petrenko
2020-04-23 14:06 ` Konstantin Osipov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox