From 377ef1f9f3701a8c3b57158efc3fa45ab70e96bf Mon Sep 17 00:00:00 2001 From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Date: Wed, 19 Jun 2019 00:28:23 +0200 Subject: [PATCH] swim: deliver incarnation update on URI reconfig 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. --- src/lib/swim/swim.c | 2 ++ test/swim/swim.result | 5 +++-- test/unit/swim.c | 22 ++++++++++++++++++++-- test/unit/swim.result | 3 ++- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/lib/swim/swim.c b/src/lib/swim/swim.c index 00234d1df5..2b37d41e01 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 535c8c9699..cceee25950 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 0e33d691cd..0977e09694 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(); } diff --git a/test/unit/swim.result b/test/unit/swim.result index 3ebfe7ea0a..2968a2da70 100644 --- a/test/unit/swim.result +++ b/test/unit/swim.result @@ -201,7 +201,7 @@ ok 19 - subtests ok 20 - subtests *** swim_test_slow_net: done *** *** swim_test_triggers *** - 1..21 + 1..22 ok 1 - trigger is fired ok 2 - is not deleted ok 3 - ctx.member is set @@ -224,6 +224,7 @@ ok 20 - subtests ok 20 - non-yielding still is not ok 21 - trigger is not deleted until all currently sleeping triggers are finished # now all the triggers are done and deleted + ok 22 - local URI update warns about incarnation update ok 21 - subtests *** swim_test_triggers: done *** *** main_f: done *** -- GitLab