[tarantool-patches] [PATCH 1/2] box: make replication_sync_lag option dynamic

Vladimir Davydov vdavydov.dev at gmail.com
Tue Aug 28 17:03:14 MSK 2018


On Tue, Aug 28, 2018 at 02:43:27PM +0300, Olga Arkhangelskaia wrote:
> In gh-3427 replication_sync_lag should be taken into account during
> replication reconfiguration. In order to configure replication properly
> this parameter is made dynamical and can be changed on demand.
> 
> @TarantoolBot document
> Title: recation_sync_lag option can be set dynamically
> recation_sync_lag now can be set at any time.
> ---
>  src/box/box.cc            |  6 ++++++
>  src/box/box.h             |  1 +
>  src/box/lua/cfg.cc        | 12 ++++++++++++
>  src/box/lua/load_cfg.lua  |  1 +
>  test/box-tap/cfg.test.lua |  4 +++-
>  5 files changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/src/box/box.cc b/src/box/box.cc
> index 8d7454d1f..be5077da8 100644
> --- a/src/box/box.cc
> +++ b/src/box/box.cc
> @@ -656,6 +656,12 @@ box_set_replication_connect_quorum(void)
>  		replicaset_check_quorum();
>  }
>  
> +void
> +box_set_replication_sync_lag(void)
> +{
> +	replication_sync_lag = box_check_replication_sync_lag();
> +}
> +

Nit: you can now use this function in box_cfg_xc() instead of

	replication_sync_lag = box_check_replication_sync_lag();

Please do.

>  void
>  box_bind(void)
>  {
> diff --git a/src/box/box.h b/src/box/box.h
> index 9dfb3fd2a..3090fdcdb 100644
> --- a/src/box/box.h
> +++ b/src/box/box.h
> @@ -176,6 +176,7 @@ void box_set_vinyl_timeout(void);
>  void box_set_replication_timeout(void);
>  void box_set_replication_connect_timeout(void);
>  void box_set_replication_connect_quorum(void);
> +void box_set_replication_sync_lag(void);
>  
>  extern "C" {
>  #endif /* defined(__cplusplus) */
> diff --git a/src/box/lua/cfg.cc b/src/box/lua/cfg.cc
> index 0ca150877..5442723b5 100644
> --- a/src/box/lua/cfg.cc
> +++ b/src/box/lua/cfg.cc
> @@ -262,6 +262,17 @@ lbox_cfg_set_replication_connect_quorum(struct lua_State *L)
>  	return 0;
>  }
>  
> +static int
> +lbox_cfg_set_replication_sync_lag(struct lua_State *L)
> +{
> +	try {
> +		box_set_replication_sync_lag();
> +	} catch (Exception *) {
> +		luaT_error(L);
> +	}
> +	return 0;
> +}
> +
>  void
>  box_lua_cfg_init(struct lua_State *L)
>  {
> @@ -286,6 +297,7 @@ box_lua_cfg_init(struct lua_State *L)
>  		{"cfg_set_replication_timeout", lbox_cfg_set_replication_timeout},
>  		{"cfg_set_replication_connect_timeout", lbox_cfg_set_replication_connect_timeout},
>  		{"cfg_set_replication_connect_quorum", lbox_cfg_set_replication_connect_quorum},
> +		{"cfg_set_replication_sync_lag", lbox_cfg_set_replication_sync_lag},
>  		{NULL, NULL}
>  	};
>  
> diff --git a/src/box/lua/load_cfg.lua b/src/box/lua/load_cfg.lua
> index 2a7142de6..cdee475d5 100644
> --- a/src/box/lua/load_cfg.lua
> +++ b/src/box/lua/load_cfg.lua
> @@ -211,6 +211,7 @@ local dynamic_cfg = {
>                        'Can\'t change replicaset uuid')
>          end
>      end,
> +    replication_sync_lag    = private.cfg_set_replication_sync_lag,

Nit: please move this option definition closer to replication_timeout
and friends.

Also, you should add this option to dynamic_cfg_skip_at_load, because it
is initialized by box_cfg_xc().

>  }
>  
>  local dynamic_cfg_skip_at_load = {
> diff --git a/test/box-tap/cfg.test.lua b/test/box-tap/cfg.test.lua
> index 5e72004ca..7cb2ed9a3 100755
> --- a/test/box-tap/cfg.test.lua
> +++ b/test/box-tap/cfg.test.lua
> @@ -6,7 +6,7 @@ local socket = require('socket')
>  local fio = require('fio')
>  local uuid = require('uuid')
>  local msgpack = require('msgpack')
> -test:plan(90)
> +test:plan(92)
>  
>  --------------------------------------------------------------------------------
>  -- Invalid values
> @@ -32,6 +32,8 @@ invalid('replication_sync_lag', 0)
>  invalid('replication_connect_timeout', -1)
>  invalid('replication_connect_timeout', 0)
>  invalid('replication_connect_quorum', -1)
> +invalid('replication_sync_lag', -1)
> +invalid('replication_sync_lag', -1)

The same value is tested twice. Besides, this is already tested a few
lines above.

What you should test is that replication_sync_lag can now be changed
after initial configuration. Please do.

>  invalid('wal_mode', 'invalid')
>  invalid('rows_per_wal', -1)
>  invalid('listen', '//!')



More information about the Tarantool-patches mailing list