[tarantool-patches] [PATCH 4/7] swim: set 'left' status in self on swim_quit()
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Wed May 15 02:06:22 MSK 2019
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)
More information about the Tarantool-patches
mailing list