From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 2C1FE29EEE for ; Wed, 29 Aug 2018 14:57:04 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ixb9eP3ZOKRX for ; Wed, 29 Aug 2018 14:57:04 -0400 (EDT) Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id D105F28076 for ; Wed, 29 Aug 2018 14:57:03 -0400 (EDT) Received: by mail-lj1-f176.google.com with SMTP id f1-v6so5244526ljc.9 for ; Wed, 29 Aug 2018 11:57:03 -0700 (PDT) From: Olga Arkhangelskaia Subject: [tarantool-patches] [PATCH v2 1/3] box: make replication_sync_lag option dynamic Date: Wed, 29 Aug 2018 21:56:40 +0300 Message-Id: <20180829185642.49479-1-krishtal.olja@gmail.com> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: Olga Arkhangelskaia 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. --- https://github.com/tarantool/tarantool/tree/OKriw/gh-3427-replication-no-sync-1.9 v1: https://www.freelists.org/post/tarantool-patches/PATCH-12-box-make-replication-sync-lag-option-dynamic Changed in v2: -fixed test src/box/box.cc | 8 +++++++- src/box/box.h | 1 + src/box/lua/cfg.cc | 12 ++++++++++++ src/box/lua/load_cfg.lua | 2 ++ test/box-tap/cfg.test.lua | 7 ++++++- 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/box/box.cc b/src/box/box.cc index 8d7454d1f..7155ad085 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(); +} + void box_bind(void) { @@ -1747,7 +1753,7 @@ box_cfg_xc(void) box_set_replication_timeout(); box_set_replication_connect_timeout(); box_set_replication_connect_quorum(); - replication_sync_lag = box_check_replication_sync_lag(); + box_set_replication_sync_lag(); xstream_create(&join_stream, apply_initial_join_row); xstream_create(&subscribe_stream, apply_row); 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..f803d8987 100644 --- a/src/box/lua/load_cfg.lua +++ b/src/box/lua/load_cfg.lua @@ -199,6 +199,7 @@ local dynamic_cfg = { replication_timeout = private.cfg_set_replication_timeout, replication_connect_timeout = private.cfg_set_replication_connect_timeout, replication_connect_quorum = private.cfg_set_replication_connect_quorum, + replication_sync_lag = private.cfg_set_replication_sync_lag, instance_uuid = function() if box.cfg.instance_uuid ~= box.info.uuid then box.error(box.error.CFG, 'instance_uuid', @@ -220,6 +221,7 @@ local dynamic_cfg_skip_at_load = { replication_timeout = true, replication_connect_timeout = true, replication_connect_quorum = true, + replication_sync_lag = true, wal_dir_rescan_delay = true, custom_proc_title = true, force_recovery = true, diff --git a/test/box-tap/cfg.test.lua b/test/box-tap/cfg.test.lua index 5e72004ca..d315346de 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(91) -------------------------------------------------------------------------------- -- Invalid values @@ -95,6 +95,11 @@ test:ok(status and result == 'table', 'configured box') invalid('log_level', 'unknown') +lag = box.cfg.replication_sync_lag +status, result = pcall(box.cfg, {replication_sync_lag = 1}) +test:ok(status, "dynamic replication_sync_lag") +pcall(box.cfg, {repliction_sync_lag = lag}) + -------------------------------------------------------------------------------- -- gh-534: Segmentation fault after two bad wal_mode settings -------------------------------------------------------------------------------- -- 2.14.3 (Apple Git-98)