Skip to content
Snippets Groups Projects
Commit 8cb0206b authored by Vladislav Shpilevoy's avatar Vladislav Shpilevoy
Browse files

swim: set 'left' status in self on swim_quit()

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
parent 2149496b
No related branches found
No related tags found
No related merge requests found
......@@ -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 *
......
......@@ -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);
......
......@@ -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 ***
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment