From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: tarantool-patches@freelists.org Cc: vdavydov.dev@gmail.com Subject: [PATCH 4/5] swim: introduce "suspected" status Date: Mon, 17 Dec 2018 15:53:22 +0300 [thread overview] Message-ID: <97ea4d96f89601abde2de182b94a65240816208a.1545047950.git.v.shpilevoy@tarantool.org> (raw) In-Reply-To: <cover.1545047950.git.v.shpilevoy@tarantool.org> In-Reply-To: <cover.1545047950.git.v.shpilevoy@tarantool.org> Now a member dies "gradually". After some failed pings it is declared as suspected. After more failed pings it is finaly dead. New members in a config are declared as suspected because the instance can not be sure whether they are alive or not. Follow up #3234 --- src/lib/swim/swim.c | 26 +++++++++++++++++++++++--- test/swim/basic.result | 26 +++++++++++++------------- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/lib/swim/swim.c b/src/lib/swim/swim.c index bbf6b7fd5..df57ef470 100644 --- a/src/lib/swim/swim.c +++ b/src/lib/swim/swim.c @@ -156,6 +156,12 @@ enum swim_member_status { * members table. */ MEMBER_ALIVE = 0, + /** + * If a member has not responded to a ping, it is declared + * as suspected to be dead. After more failed pings it + * is finaly dead. + */ + MEMBER_SUSPECTED, /** * The member is considered to be dead. It will disappear * from the membership, if it is not pinned. @@ -166,6 +172,7 @@ enum swim_member_status { static const char *swim_member_status_strs[] = { "alive", + "suspected", "dead", }; @@ -596,9 +603,15 @@ enum { ACK_TIMEOUT = 1, /** * If a member has not been responding to pings this - * number of times, it is considered to be dead. + * number of times, it is suspected to be dead. To confirm + * the death it should fail more pings. */ - NO_ACKS_TO_DEAD = 3, + NO_ACKS_TO_SUSPECT = 2, + /** + * If a member is suspected to be dead, after this number + * of failed pings its death is confirmed. + */ + NO_ACKS_TO_DEAD = NO_ACKS_TO_SUSPECT + 2, /** * If a not pinned member confirmed to be dead, it is * removed from the membership after at least this number @@ -1015,6 +1028,9 @@ swim_check_acks(struct ev_loop *loop, struct ev_periodic *p, int events) if (m->failed_pings >= NO_ACKS_TO_DEAD) { m->status = MEMBER_DEAD; swim_member_is_updated(m); + } else if (m->failed_pings >= NO_ACKS_TO_SUSPECT) { + m->status = MEMBER_SUSPECTED; + swim_member_is_updated(m); } swim_io_task_push(&m->ping_task); rlist_del_entry(m, in_queue_wait_ack); @@ -1505,7 +1521,11 @@ swim_cfg(const char **member_uris, int member_uri_count, const char *server_uri, free(cfg); for (int i = 0; i < new_cfg_size; ++i) { new_cfg[i]->is_pinned = true; - new_cfg[i]->status = MEMBER_ALIVE; + /* + * Real status is unknown, so a new member + * can not be alive. + */ + new_cfg[i]->status = MEMBER_SUSPECTED; } cfg = new_cfg; cfg_size = new_cfg_size; diff --git a/test/swim/basic.result b/test/swim/basic.result index 7d0131606..f223950a6 100644 --- a/test/swim/basic.result +++ b/test/swim/basic.result @@ -42,13 +42,13 @@ swim.cfg({members = members}) swim_info_sorted() --- - - - 192.168.0.1:3333 - - status: alive + - status: suspected incarnation: 0 - - 192.168.0.2:3333 - - status: alive + - status: suspected incarnation: 0 - - 192.168.0.3:3333 - - status: alive + - status: suspected incarnation: 0 ... swim.stop() @@ -68,13 +68,13 @@ swim_info_sorted() - status: alive incarnation: 0 - - 192.168.0.1:3333 - - status: alive + - status: suspected incarnation: 0 - - 192.168.0.2:3333 - - status: alive + - status: suspected incarnation: 0 - - 192.168.0.3:3333 - - status: alive + - status: suspected incarnation: 0 ... swim.debug_round_step() @@ -86,13 +86,13 @@ swim_info_sorted() - status: alive incarnation: 0 - - 192.168.0.1:3333 - - status: alive + - status: suspected incarnation: 0 - - 192.168.0.2:3333 - - status: alive + - status: suspected incarnation: 0 - - 192.168.0.3:3333 - - status: alive + - status: suspected incarnation: 0 ... swim.stop() @@ -174,16 +174,16 @@ swim.cfg({server = listen_uri, members = members}) swim_info_sorted() --- - - - 127.0.0.1:listen_port - - status: alive + - status: suspected incarnation: 0 - - 192.168.0.1:3333 - - status: alive + - status: suspected incarnation: 0 - - 192.168.0.2:3333 - - status: alive + - status: suspected incarnation: 0 - - 192.168.0.3:3333 - - status: alive + - status: suspected incarnation: 0 ... swim.stop() -- 2.17.2 (Apple Git-113)
next prev parent reply other threads:[~2018-12-17 12:53 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-12-17 12:53 [PATCH 0/5] SWIM Vladislav Shpilevoy 2018-12-17 12:53 ` [PATCH 1/5] swim: introduce SWIM's anti-entropy component Vladislav Shpilevoy 2018-12-17 12:53 ` [PATCH 2/5] swim: introduce failure detection component Vladislav Shpilevoy 2018-12-17 12:53 ` [PATCH 3/5] swim: introduce a dissemination component Vladislav Shpilevoy 2018-12-17 12:53 ` Vladislav Shpilevoy [this message] 2018-12-17 12:53 ` [PATCH 5/5] swim: keep encoded round message cached 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=97ea4d96f89601abde2de182b94a65240816208a.1545047950.git.v.shpilevoy@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=vdavydov.dev@gmail.com \ --subject='Re: [PATCH 4/5] swim: introduce "suspected" status' \ /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