[tarantool-patches] [PATCH 1/1] swim: deliver incarnation update on URI reconfig

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Wed Jun 19 01:32:05 MSK 2019


URI reconfiguration causes incarnation increment in order to
forcefully rewrite old value on remote instances. But that update
was not delivered to a user via triggers. The patch fixes that.
---
Branch: https://github.com/tarantool/tarantool/tree/gerold103/swim-cfg-uri-trigger

 src/lib/swim/swim.c   |  2 ++
 test/swim/swim.result |  5 +++--
 test/unit/swim.c      | 22 ++++++++++++++++++++--
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/src/lib/swim/swim.c b/src/lib/swim/swim.c
index 00234d1df..2b37d41e0 100644
--- a/src/lib/swim/swim.c
+++ b/src/lib/swim/swim.c
@@ -1960,6 +1960,8 @@ swim_cfg(struct swim *swim, const char *uri, double heartbeat_rate,
 	}
 	if (! swim_inaddr_eq(&addr, &swim->self->addr)) {
 		swim->self->incarnation++;
+		swim_on_member_update(swim, swim->self,
+				      SWIM_EV_NEW_INCARNATION);
 		swim_update_member_addr(swim, swim->self, &addr);
 	}
 	if (gc_mode != SWIM_GC_DEFAULT)
diff --git a/test/swim/swim.result b/test/swim/swim.result
index 535c8c969..cceee2595 100644
--- a/test/swim/swim.result
+++ b/test/swim/swim.result
@@ -1293,10 +1293,11 @@ m_list
 ...
 e_list
 ---
-- - is_new_payload: true
+- - is_update: true
+    is_new_payload: true
     is_new_uri: true
     is_new: true
-    is_update: true
+    is_new_incarnation: true
 ...
 ctx_list
 ---
diff --git a/test/unit/swim.c b/test/unit/swim.c
index 0e33d691c..0977e0969 100644
--- a/test/unit/swim.c
+++ b/test/unit/swim.c
@@ -998,7 +998,7 @@ swim_cluster_delete_f(va_list ap)
 static void
 swim_test_triggers(void)
 {
-	swim_start_test(21);
+	swim_start_test(22);
 	struct swim_cluster *cluster = swim_cluster_new(2);
 	swim_cluster_set_ack_timeout(cluster, 1);
 	struct trigger_ctx tctx, tctx2;
@@ -1085,11 +1085,29 @@ swim_test_triggers(void)
 		fiber_sleep(0);
 	note("now all the triggers are done and deleted");
 
-	free(t1);
 	free(t2);
 	if (tctx.ctx.member != NULL)
 		swim_member_unref(tctx.ctx.member);
 
+	/* Check that recfg fires incarnation update trigger. */
+	s1 = swim_new();
+	struct tt_uuid uuid = uuid_nil;
+	uuid.time_low = 1;
+	fail_if(swim_cfg(s1, "127.0.0.1:1", -1, -1, -1, &uuid) != 0);
+
+	memset(&tctx, 0, sizeof(tctx));
+	trigger_add(swim_trigger_list_on_member_event(s1), t1);
+	fail_if(swim_cfg(s1, "127.0.0.1:2", -1, -1, -1, NULL) != 0);
+	while (tctx.ctx.events == 0)
+		fiber_sleep(0);
+	is(tctx.ctx.events, SWIM_EV_NEW_URI | SWIM_EV_NEW_INCARNATION,
+	   "local URI update warns about incarnation update");
+	swim_delete(s1);
+
+	if (tctx.ctx.member != NULL)
+		swim_member_unref(tctx.ctx.member);
+	free(t1);
+
 	swim_finish_test();
 }
 
-- 
2.20.1 (Apple Git-117)





More information about the Tarantool-patches mailing list