Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: kostja@tarantool.org
Subject: [tarantool-patches] [PATCH 1/1] swim: deliver incarnation update on URI reconfig
Date: Wed, 19 Jun 2019 00:32:05 +0200	[thread overview]
Message-ID: <49954bc5af7471e8cbe5db603316532025298537.1560897097.git.v.shpilevoy@tarantool.org> (raw)

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)

             reply	other threads:[~2019-06-18 22:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-18 22:32 Vladislav Shpilevoy [this message]
2019-06-19 18:14 ` [tarantool-patches] " Konstantin Osipov
2019-06-19 20:30   ` Vladislav Shpilevoy

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=49954bc5af7471e8cbe5db603316532025298537.1560897097.git.v.shpilevoy@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH 1/1] swim: deliver incarnation update on URI reconfig' \
    /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