From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id E868E30387 for ; Tue, 18 Jun 2019 18:31:39 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HikUGdnxB3s5 for ; Tue, 18 Jun 2019 18:31:39 -0400 (EDT) Received: from smtp55.i.mail.ru (smtp55.i.mail.ru [217.69.128.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 4C1A930382 for ; Tue, 18 Jun 2019 18:31:39 -0400 (EDT) From: Vladislav Shpilevoy Subject: [tarantool-patches] [PATCH 1/1] swim: deliver incarnation update on URI reconfig Date: Wed, 19 Jun 2019 00:32:05 +0200 Message-Id: <49954bc5af7471e8cbe5db603316532025298537.1560897097.git.v.shpilevoy@tarantool.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: kostja@tarantool.org 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)