From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH v2 2/3] box: don't set cluster uuid and instance id in initial snapshot Date: Fri, 15 Feb 2019 15:25:48 +0300 Message-Id: <2686110152a446ba3d039cf0a644b1c6d102f813.1550232829.git.vdavydov.dev@gmail.com> In-Reply-To: References: In-Reply-To: References: To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: They aren't needed there as we reset them anyway once the snapshot is replayed on initial bootstrap. OTOH having them results in calling replica_{set,clear}_id twice on initial bootstrap, which will look weird when I patch them to log the ids. So let's remove them from the initial snapshot. This makes the initial bootstrap impossible to recover from as it is, but that shouldn't be an issue since one can always bootstrap a new instance in a normal way. This also allows us to make cluster uuid truly immutable (currently, one can update it with REPLACE). --- src/box/alter.cc | 2 +- src/box/bootstrap.snap | Bin 1911 -> 1831 bytes src/box/box.cc | 6 +----- src/box/lua/upgrade.lua | 7 ++++--- test/box-py/bootstrap.result | 5 ++--- test/box-py/bootstrap.test.py | 16 +++------------- test/replication/misc.result | 9 ++++++++- test/replication/misc.test.lua | 5 ++++- 8 files changed, 23 insertions(+), 27 deletions(-) diff --git a/src/box/alter.cc b/src/box/alter.cc index 6e0ed973..de8372b3 100644 --- a/src/box/alter.cc +++ b/src/box/alter.cc @@ -3012,7 +3012,7 @@ on_replace_dd_schema(struct trigger * /* trigger */, void *event) const char *key = tuple_field_cstr_xc(new_tuple ? new_tuple : old_tuple, BOX_SCHEMA_FIELD_KEY); if (strcmp(key, "cluster") == 0) { - if (new_tuple == NULL) + if (old_tuple != NULL) tnt_raise(ClientError, ER_REPLICASET_UUID_IS_RO); tt_uuid uu; tuple_field_uuid_xc(new_tuple, BOX_CLUSTER_FIELD_UUID, &uu); diff --git a/src/box/bootstrap.snap b/src/box/bootstrap.snap index d6cc821fbf449852b62aace82a2c751e7f328365..0bb446fb6903ac3ef630c419b909f7db3df0372a 100644 GIT binary patch delta 1827 zcmV+;2i*Ag4yO)~8GkZ0H7#c}H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-Mi@An<;2&gd{cG!-&K8-wdm3NZ#&`GLWf0givTzH+J|nz zRZ)&ej;x_-MVwD#`G2o11jR2TN*t2i)?KngnV*P3N3RxIi5&4disNHD($!kVQFq%n zqXVnj07fyL%id == 1); diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua index 3d9acc97..70cfb4f2 100644 --- a/src/box/lua/upgrade.lua +++ b/src/box/lua/upgrade.lua @@ -71,6 +71,8 @@ local function set_system_triggers(val) box.space._priv:run_triggers(val) box.space._trigger:run_triggers(val) box.space._collation:run_triggers(val) + box.space._schema:run_triggers(val) + box.space._cluster:run_triggers(val) end -------------------------------------------------------------------------------- @@ -88,9 +90,8 @@ local function erase() truncate(box.space._truncate) truncate(box.space._collation) truncate(box.space._trigger) - --truncate(box.space._schema) - box.space._schema:delete('version') - box.space._schema:delete('max_id') + truncate(box.space._schema) + truncate(box.space._cluster) end local function create_sysview(source_id, target_id) diff --git a/test/box-py/bootstrap.result b/test/box-py/bootstrap.result index 506aca3d..3e439455 100644 --- a/test/box-py/bootstrap.result +++ b/test/box-py/bootstrap.result @@ -3,13 +3,12 @@ box.internal.bootstrap() ... box.space._schema:select{} --- -- - ['cluster', ''] - - ['max_id', 511] +- - ['max_id', 511] - ['version', 2, 1, 0] ... box.space._cluster:select{} --- -- - [1, ''] +- [] ... box.space._space:select{} --- diff --git a/test/box-py/bootstrap.test.py b/test/box-py/bootstrap.test.py index 9d690b03..4f2f55a7 100644 --- a/test/box-py/bootstrap.test.py +++ b/test/box-py/bootstrap.test.py @@ -1,16 +1,4 @@ - -import sys -import yaml - -server_uuid = server.get_param('uuid') -sys.stdout.push_filter(server_uuid, '') -cluster_uuid = yaml.load(server.admin('box.space._schema:get("cluster")', - silent = True))[0][1] -sys.stdout.push_filter(cluster_uuid, '') - server.admin('box.internal.bootstrap()') -server.restart() - server.admin('box.space._schema:select{}') server.admin('box.space._cluster:select{}') server.admin('box.space._space:select{}') @@ -20,4 +8,6 @@ server.admin('box.space._func:select{}') server.admin('box.space._priv:select{}') # Cleanup -sys.stdout.pop_filter() +server.stop() +server.cleanup() +server.deploy() diff --git a/test/replication/misc.result b/test/replication/misc.result index ab827c50..684d7f7c 100644 --- a/test/replication/misc.result +++ b/test/replication/misc.result @@ -627,11 +627,18 @@ box.info.replication[2].downstream.status - follow ... -- change master's cluster uuid and check that replica doesn't connect. +test_run:cmd("restart server default with cleanup=1") +box.schema.user.grant("guest", "replication") +--- +... +replica_uuid = test_run:eval("replica", "box.info.uuid")[1] +--- +... test_run:cmd("stop server replica") --- - true ... -_ = box.space._schema:replace{'cluster', tostring(uuid.new())} +_ = box.space._cluster:insert{2, replica_uuid} --- ... -- master believes replica is in cluster, but their cluster UUIDs differ. diff --git a/test/replication/misc.test.lua b/test/replication/misc.test.lua index eda5310b..b0b64dc7 100644 --- a/test/replication/misc.test.lua +++ b/test/replication/misc.test.lua @@ -253,8 +253,11 @@ test_run:cmd("start server replica") test_run:grep_log("replica", "REPLICASET_UUID_MISMATCH") box.info.replication[2].downstream.status -- change master's cluster uuid and check that replica doesn't connect. +test_run:cmd("restart server default with cleanup=1") +box.schema.user.grant("guest", "replication") +replica_uuid = test_run:eval("replica", "box.info.uuid")[1] test_run:cmd("stop server replica") -_ = box.space._schema:replace{'cluster', tostring(uuid.new())} +_ = box.space._cluster:insert{2, replica_uuid} -- master believes replica is in cluster, but their cluster UUIDs differ. test_run:cmd("start server replica") test_run:wait_log("replica", "REPLICASET_UUID_MISMATCH", nil, 1.0) -- 2.11.0