[Tarantool-patches] [PATCH v3] qsync: provide box.info interface for monitoring

Serge Petrenko sergepetrenko at tarantool.org
Thu Apr 8 10:34:56 MSK 2021



05.04.2021 23:34, Cyrill Gorcunov пишет:
> Guys, here is an updated version. Take a look please.
> Vlad, lets stick with simple version and will add
> `queues` array if we ever really need to.
Hi! Thanks for the patch!

Please find one comment below.

>
> issue https://github.com/tarantool/tarantool/issues/5191
> branch gorcunov/gh-5191-qsync-stat-3
> ---
>
> diff --git a/src/box/lua/info.c b/src/box/lua/info.c
> index 8cd379756..a2ffff4b5 100644
> --- a/src/box/lua/info.c
> +++ b/src/box/lua/info.c
> @@ -50,6 +50,7 @@
>   #include "version.h"
>   #include "box/box.h"
>   #include "box/raft.h"
> +#include "box/txn_limbo.h"
>   #include "lua/utils.h"
>   #include "fiber.h"
>   #include "sio.h"
> @@ -599,6 +600,29 @@ lbox_info_election(struct lua_State *L)
>   	return 1;
>   }
>   
> +static int
> +lbox_info_synchro(struct lua_State *L)
> +{
> +	lua_newtable(L);

Maybe change to lua_createtable(L, 0, 2) ?
This will be consistent with what is done below, and lua doc
states that'll be a bit faster:
https://www.lua.org/manual/5.3/manual.html#lua_newtable
(sorry, a direct link to lua_createtable didn't work)

> +
> +	/* Quorum value may be evaluated via formula */
> +	lua_pushinteger(L, replication_synchro_quorum);
> +	lua_setfield(L, -2, "quorum");
> +
> +	/*
> +	 * Queue information.
> +	 */
> +	struct txn_limbo *queue = &txn_limbo;
> +	lua_createtable(L, 0, 1);
> +	lua_pushstring(L, "len");
> +	lua_pushnumber(L, queue->len);
> +	lua_settable(L, -3);
> +	lua_setfield(L, -2, "queue");
> +
> +	return 1;
> +}
> +
> +
>   static const struct luaL_Reg lbox_info_dynamic_meta[] = {
>   	{"id", lbox_info_id},
>   	{"uuid", lbox_info_uuid},
> @@ -618,6 +642,7 @@ static const struct luaL_Reg lbox_info_dynamic_meta[] = {
>   	{"sql", lbox_info_sql},
>   	{"listen", lbox_info_listen},
>   	{"election", lbox_info_election},
> +	{"synchro", lbox_info_synchro},
>   	{NULL, NULL}
>   };
>
-- 
Serge Petrenko



More information about the Tarantool-patches mailing list