[PATCH] replication: move cluster id match check to replica

Vladimir Davydov vdavydov.dev at gmail.com
Thu Feb 7 13:14:51 MSK 2019


Pushed to 2.1 with some minor changes:

diff --git a/src/box/applier.cc b/src/box/applier.cc
index 045c6910..512d05df 100644
--- a/src/box/applier.cc
+++ b/src/box/applier.cc
@@ -410,7 +410,7 @@ applier_subscribe(struct applier *applier)
 		 * In case of successful subscribe, the server
 		 * responds with its current vclock.
 		 *
-		 * Tarantool 2.1.1 also sends its cluster id to
+		 * Tarantool > 2.1.1 also sends its cluster id to
 		 * the replica, and replica has to check whether
 		 * its and master's cluster ids match.
 		 */
@@ -423,7 +423,7 @@ applier_subscribe(struct applier *applier)
 		 * assume that it has done all the checks.
 		 * In this case cluster_id will remain zero.
 		 */
-		if (!tt_uuid_is_equal(&cluster_id, &uuid_nil) &&
+		if (!tt_uuid_is_nil(&cluster_id) &&
 		    !tt_uuid_is_equal(&cluster_id, &REPLICASET_UUID)) {
 			tnt_raise(ClientError, ER_REPLICASET_UUID_MISMATCH,
 				  tt_uuid_str(&cluster_id),
diff --git a/src/box/box.cc b/src/box/box.cc
index 8a8c0816..e12a1cba 100644
--- a/src/box/box.cc
+++ b/src/box/box.cc
@@ -1609,11 +1609,11 @@ box_process_subscribe(struct ev_io *io, struct xrow_header *header)
 	 * the replica how many rows we have in stock for it,
 	 * and identify ourselves with our own replica id.
 	 *
-	 * Since Tarantool version 2.1.1 master doesn't check
-	 * that replica and master have the same cluster id.
-	 * It sends its cluster id to replica instead, and replica
-	 * checks that its cluster id matches master's one.
-	 * Older versions will just ignore the additional field.
+	 * Tarantool > 2.1.1 master doesn't check that replica
+	 * has the same cluster id. Instead it sends its cluster
+	 * id to replica, and replica checks that its cluster id
+	 * matches master's one. Older versions will just ignore
+	 * the additional field.
 	 */
 	struct xrow_header row;
 	xrow_encode_subscribe_response_xc(&row,
diff --git a/test/replication/misc.result b/test/replication/misc.result
index 2401ac5c..ab827c50 100644
--- a/test/replication/misc.result
+++ b/test/replication/misc.result
@@ -634,7 +634,7 @@ test_run:cmd("stop server replica")
 _ = box.space._schema:replace{'cluster', tostring(uuid.new())}
 ---
 ...
--- master believes replica is in cluster, but their cluster UUIDS differ.
+-- master believes replica is in cluster, but their cluster UUIDs differ.
 test_run:cmd("start server replica")
 ---
 - true
@@ -647,7 +647,6 @@ box.info.replication[2].downstream.status
 ---
 - stopped
 ...
-test_run:cmd("restart server default with cleanup=1")
 test_run:cmd("stop server replica")
 ---
 - true
@@ -660,3 +659,9 @@ test_run:cmd("delete server replica")
 ---
 - true
 ...
+test_run:cleanup_cluster()
+---
+...
+box.schema.user.revoke('guest', 'replication')
+---
+...
diff --git a/test/replication/misc.test.lua b/test/replication/misc.test.lua
index a1ddf75a..eda5310b 100644
--- a/test/replication/misc.test.lua
+++ b/test/replication/misc.test.lua
@@ -255,12 +255,13 @@ box.info.replication[2].downstream.status
 -- change master's cluster uuid and check that replica doesn't connect.
 test_run:cmd("stop server replica")
 _ = box.space._schema:replace{'cluster', tostring(uuid.new())}
--- master believes replica is in cluster, but their cluster UUIDS differ.
+-- 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)
 box.info.replication[2].downstream.status
 
-test_run:cmd("restart server default with cleanup=1")
 test_run:cmd("stop server replica")
 test_run:cmd("cleanup server replica")
 test_run:cmd("delete server replica")
+test_run:cleanup_cluster()
+box.schema.user.revoke('guest', 'replication')



More information about the Tarantool-patches mailing list