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 592C02EA41 for ; Tue, 14 May 2019 19:06:30 -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 Pxnp1PW1WoBY for ; Tue, 14 May 2019 19:06:30 -0400 (EDT) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 EF08B2740B for ; Tue, 14 May 2019 19:06:29 -0400 (EDT) From: Vladislav Shpilevoy Subject: [tarantool-patches] [PATCH 4/7] swim: set 'left' status in self on swim_quit() Date: Wed, 15 May 2019 02:06:22 +0300 Message-Id: <3671fe6062b6ba122d63d18cd0276e30a0e9dced.1557875116.git.v.shpilevoy@tarantool.org> In-Reply-To: References: 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 swim_quit() notifies all the members that this instance has left the cluster. Strangely, except self. It is not a real bug, but showing 'left' status in self struct swim_member would be more correct than 'alive', obviously. It is possible, that self struct swim_member was referenced by a user - this is how 'self' can be available after SWIM instance deletion. Part of #3234 --- src/lib/swim/swim.c | 1 + test/unit/swim.c | 10 ++++++++-- test/unit/swim.result | 21 +++++++++++---------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/lib/swim/swim.c b/src/lib/swim/swim.c index 7a43fae1b..54c5b3250 100644 --- a/src/lib/swim/swim.c +++ b/src/lib/swim/swim.c @@ -2002,6 +2002,7 @@ swim_quit(struct swim *swim) assert(rc == 2); mp_encode_map(header, rc); swim_quit_step_complete(task, &swim->scheduler, 0); + swim->self->status = MEMBER_LEFT; } struct swim_member * diff --git a/test/unit/swim.c b/test/unit/swim.c index 3ec25c5d0..d9613e8e0 100644 --- a/test/unit/swim.c +++ b/test/unit/swim.c @@ -502,14 +502,20 @@ swim_test_undead(void) static void swim_test_quit(void) { - swim_start_test(9); + swim_start_test(10); int size = 3; struct swim_cluster *cluster = swim_cluster_new(size); for (int i = 0; i < size; ++i) { for (int j = 0; j < size; ++j) swim_cluster_add_link(cluster, i, j); } + struct swim *s0 = swim_cluster_member(cluster, 0); + struct swim_member *s0_self = swim_self(s0); + swim_member_ref(s0_self); swim_cluster_quit_node(cluster, 0); + is(swim_member_status(s0_self), MEMBER_LEFT, + "'self' is 'left' immediately after quit"); + swim_member_unref(s0_self); is(swim_cluster_wait_status_everywhere(cluster, 0, MEMBER_LEFT, 0), 0, "'quit' is sent to all the members without delays between "\ "dispatches") @@ -528,7 +534,7 @@ swim_test_quit(void) * received the 'quit' message with the same UUID. Of * course, it should be refuted. */ - struct swim *s0 = swim_cluster_member(cluster, 0); + s0 = swim_cluster_member(cluster, 0); struct tt_uuid s0_uuid = *swim_member_uuid(swim_self(s0)); struct swim *s1 = swim_cluster_member(cluster, 1); swim_remove_member(s1, &s0_uuid); diff --git a/test/unit/swim.result b/test/unit/swim.result index 0d1fa4a32..266d83589 100644 --- a/test/unit/swim.result +++ b/test/unit/swim.result @@ -122,16 +122,17 @@ ok 11 - subtests ok 12 - subtests *** swim_test_packet_loss: done *** *** swim_test_quit *** - 1..9 - ok 1 - 'quit' is sent to all the members without delays between dispatches - ok 2 - quited member S1 has returned and refuted the old status - ok 3 - another member S2 has taken the quited UUID - ok 4 - S3 did not add S1 back when received its 'quit' - ok 5 - S2 finally got 'quit' message from S1, but with its 'own' UUID - refute it - ok 6 - S3 sees S1 as left - ok 7 - S2 does not see S1 at all - ok 8 - after more time S1 is dropped from S3 - ok 9 - and still is not added to S2 - left members can not be added + 1..10 + ok 1 - 'self' is 'left' immediately after quit + ok 2 - 'quit' is sent to all the members without delays between dispatches + ok 3 - quited member S1 has returned and refuted the old status + ok 4 - another member S2 has taken the quited UUID + ok 5 - S3 did not add S1 back when received its 'quit' + ok 6 - S2 finally got 'quit' message from S1, but with its 'own' UUID - refute it + ok 7 - S3 sees S1 as left + ok 8 - S2 does not see S1 at all + ok 9 - after more time S1 is dropped from S3 + ok 10 - and still is not added to S2 - left members can not be added ok 13 - subtests *** swim_test_quit: done *** *** swim_test_uri_update *** -- 2.20.1 (Apple Git-117)