Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: kostja@tarantool.org
Cc: tarantool-patches@freelists.org
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	[thread overview]
Message-ID: <2686110152a446ba3d039cf0a644b1c6d102f813.1550232829.git.vdavydov.dev@gmail.com> (raw)
In-Reply-To: <cover.1550232829.git.vdavydov.dev@gmail.com>
In-Reply-To: <cover.1550232829.git.vdavydov.dev@gmail.com>

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);
di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Mo6|T=B8$ihmcoLN#Qv
zW`~N`>gw8ZR8M1;glo6i^PHvd1pEY(&x<hFTNb}f<S>HleZ*(1sZ}bd;nqbLhnu?)
z0`og5tbB2A^d=Bhh~iUM!dCI{s;#+32u9v;>YObAvqAp~jk2!#9L;wjRQK2glSCDx
zFBkO*&!Gm{V4Rf$_slpeAAhjfv*!n#4QK>iGEW*WG{+2BNSyk+_ME_z)<IEjF@>qV
z=+eSw)<Yz2$i?pqk~>{y)|f4W?yNCQ+dpSBZ@;?|3<Pk@vAVt02zx(eiP@+7Leg!C
z@ci)%AEN_6RhEb^Q?dw$txDK}f4Qw@{mE{^qH-GS`!lg*OtodA$$u$t>4m41*-{rc
z$YmX0X@L6U{9_j+UwQ_sL%asso)ThLU&*SQl0SjPahi&z5t<wdFpNZPPrp=Z+w6~t
zQqe!|z>jmRgTbcno!<<-Mi@An<;2&gd{cG!-&K8-wdm3NZ#&`GLWf0givTzH+J|nz
zRZ)&ej;x_-MVwD#`G2o11jR2TN*t2i)?KngnV*P3N3RxIi5&4disNHD($!kVQFq%n
zqXVnj07fyL%<aF&#OW4d;1n3Aw{1{%rVHmxEDb2iB;?M5Cx+aumGhHS!ilmJ0B}=$
zz!WULsMm-KnnxJcM@xQ?&Nzj;-s0hkI*}JT?p^AkWnedXwQPsj|M;v@6md!P#-1d(
zDoP~v+qxUl;TQcxOG$3hx1zuYJJAoVS(G9}Fv@kW-Vp&@<A~A+pcq-B0!cL?`acdq
thElOZm#P0s`v^&(M?w~{P|y3<d8L3woSg;Vjxglw@t!2#kPg)lt?fmKrxpMJ

diff --git a/src/box/box.cc b/src/box/box.cc
index 6ea83a65..8136cf33 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -1661,7 +1661,7 @@ box_set_replicaset_uuid(const struct tt_uuid *replicaset_uuid)
 	else
 		tt_uuid_create(&uu);
 	/* Save replica set UUID in _schema */
-	if (boxk(IPROTO_REPLACE, BOX_SCHEMA_ID, "[%s%s]", "cluster",
+	if (boxk(IPROTO_INSERT, BOX_SCHEMA_ID, "[%s%s]", "cluster",
 		 tt_uuid_str(&uu)))
 		diag_raise();
 }
@@ -1736,10 +1736,6 @@ bootstrap_master(const struct tt_uuid *replicaset_uuid)
 
 	uint32_t replica_id = 1;
 
-	/* Unregister a local replica if it was registered by bootstrap.bin */
-	if (boxk(IPROTO_DELETE, BOX_CLUSTER_ID, "[%u]", 1) != 0)
-		diag_raise();
-
 	/* Register the first replica in the replica set */
 	box_register_replica(replica_id, &INSTANCE_UUID);
 	assert(replica_by_uuid(&INSTANCE_UUID)->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', '<cluster uuid>']
-  - ['max_id', 511]
+- - ['max_id', 511]
   - ['version', 2, 1, 0]
 ...
 box.space._cluster:select{}
 ---
-- - [1, '<server uuid>']
+- []
 ...
 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, '<server uuid>')
-cluster_uuid = yaml.load(server.admin('box.space._schema:get("cluster")',
-    silent = True))[0][1]
-sys.stdout.push_filter(cluster_uuid, '<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

  parent reply	other threads:[~2019-02-15 12:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-15 12:25 [PATCH v2 0/3] Improve replication related logging Vladimir Davydov
2019-02-15 12:25 ` [PATCH v2 1/3] vclock: use static buffer to format vclock Vladimir Davydov
2019-02-15 12:41   ` Konstantin Osipov
2019-02-15 12:25 ` Vladimir Davydov [this message]
2019-02-15 12:58   ` [tarantool-patches] Re: [PATCH v2 2/3] box: don't set cluster uuid and instance id in initial snapshot Konstantin Osipov
2019-02-15 13:00   ` Konstantin Osipov
2019-02-15 12:25 ` [PATCH v2 3/3] replication: improve join/subscribe logging Vladimir Davydov
2019-02-15 12:59   ` [tarantool-patches] " Konstantin Osipov
2019-02-15 12:26 ` [PATCH v2 0/3] Improve replication related logging Vladimir Davydov
2019-02-15 13:47 ` Vladimir Davydov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2686110152a446ba3d039cf0a644b1c6d102f813.1550232829.git.vdavydov.dev@gmail.com \
    --to=vdavydov.dev@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH v2 2/3] box: don'\''t set cluster uuid and instance id in initial snapshot' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox