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 4/7] swim: set 'left' status in self on swim_quit()
Date: Wed, 15 May 2019 02:06:22 +0300	[thread overview]
Message-ID: <3671fe6062b6ba122d63d18cd0276e30a0e9dced.1557875116.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1557875116.git.v.shpilevoy@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)

  parent reply	other threads:[~2019-05-14 23:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-14 23:06 [tarantool-patches] [PATCH 0/7] swim lua preparation, again Vladislav Shpilevoy
2019-05-14 23:06 ` [tarantool-patches] [PATCH 1/7] swim: drop swim_info() function Vladislav Shpilevoy
2019-05-15  2:00   ` [tarantool-patches] " Konstantin Osipov
2019-05-14 23:06 ` [tarantool-patches] [PATCH 2/7] swim: encapsulate 'uint16' payload size inside swim.c Vladislav Shpilevoy
2019-05-15  2:02   ` [tarantool-patches] " Konstantin Osipov
2019-05-14 23:06 ` [tarantool-patches] [PATCH 3/7] swim: do not rebind when new 'port' is 0 Vladislav Shpilevoy
2019-05-15  2:02   ` [tarantool-patches] " Konstantin Osipov
2019-05-14 23:06 ` Vladislav Shpilevoy [this message]
2019-05-15  2:03   ` [tarantool-patches] Re: [PATCH 4/7] swim: set 'left' status in self on swim_quit() Konstantin Osipov
2019-05-14 23:06 ` [tarantool-patches] [PATCH 5/7] msgpack: allow to pass 'struct ibuf *' into encode() Vladislav Shpilevoy
2019-05-15  2:05   ` [tarantool-patches] " Konstantin Osipov
2019-05-14 23:06 ` [tarantool-patches] [PATCH 6/7] msgpack: allow to pass 'const char *' into decode() Vladislav Shpilevoy
2019-05-15  2:05   ` [tarantool-patches] " Konstantin Osipov
2019-05-14 23:06 ` [tarantool-patches] [PATCH 7/7] Drop an unused function and class Vladislav Shpilevoy
2019-05-15  2:06   ` [tarantool-patches] " Konstantin Osipov
2019-05-15 10:02 ` [tarantool-patches] Re: [PATCH 0/7] swim lua preparation, again 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=3671fe6062b6ba122d63d18cd0276e30a0e9dced.1557875116.git.v.shpilevoy@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH 4/7] swim: set '\''left'\'' status in self on swim_quit()' \
    /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