From: Serge Petrenko <sergepetrenko@tarantool.org> To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>, tarantool-patches@dev.tarantool.org, gorcunov@gmail.com Subject: Re: [Tarantool-patches] [PATCH v2 01/10] applier: store instance_id in struct applier Date: Fri, 4 Sep 2020 11:13:21 +0300 [thread overview] Message-ID: <48e523a3-0507-0702-c39d-c1ef367a235a@tarantool.org> (raw) In-Reply-To: <89d43ffb6714598c377f0fdcccae61a6ab360409.1599173312.git.v.shpilevoy@tarantool.org> 04.09.2020 01:51, Vladislav Shpilevoy пишет: > Applier is going to need its numeric ID in order to tell the > future Raft module who is a sender of a Raft message. An > alternative would be to add sender ID to each Raft message, but > this looks like a crutch. Moreover, applier still needs to know > its numeric ID in order to notify Raft about heartbeats from the > peer node. > > Needed for #1146 Hi! Thanks for the patch! > --- > src/box/applier.cc | 19 +++++++++++++++++++ > src/box/applier.h | 2 ++ > 2 files changed, 21 insertions(+) > > diff --git a/src/box/applier.cc b/src/box/applier.cc > index c1d07ca54..699b5a683 100644 > --- a/src/box/applier.cc > +++ b/src/box/applier.cc > @@ -67,6 +67,23 @@ applier_set_state(struct applier *applier, enum applier_state state) > trigger_run_xc(&applier->on_state, applier); > } > > +static inline void > +applier_assign_instance_id(struct applier *applier) Maybe call it `applier_set_id`? This way it's shorter and resembles `replica_set_id`. > +{ > + /* > + * After final join, the applier already received latest > + * records from _cluster, including the record about > + * source instance. It can be absent in case the source is > + * an anonymous replica. > + */ > + assert(applier->state == APPLIER_JOINED); > + struct replica *replica = replica_by_uuid(&applier->uuid); > + if (replica != NULL) > + applier->instance_id = replica->id; > + else > + assert(applier->instance_id == 0); > +} > + > /** > * Write a nice error message to log file on SocketError or ClientError > * in applier_f(). > @@ -603,6 +620,7 @@ applier_join(struct applier *applier) > say_info("final data received"); > > applier_set_state(applier, APPLIER_JOINED); > + applier_assign_instance_id(applier); > applier_set_state(applier, APPLIER_READY); > } > > @@ -1207,6 +1225,7 @@ applier_subscribe(struct applier *applier) > instance_id != REPLICA_ID_NIL) { > say_info("final data received"); > applier_set_state(applier, APPLIER_JOINED); > + applier_assign_instance_id(applier); > applier_set_state(applier, APPLIER_READY); > applier_set_state(applier, APPLIER_FOLLOW); > } > diff --git a/src/box/applier.h b/src/box/applier.h > index 6e979a806..15ca1fcfd 100644 > --- a/src/box/applier.h > +++ b/src/box/applier.h > @@ -95,6 +95,8 @@ struct applier { > ev_tstamp lag; > /** The last box_error_code() logged to avoid log flooding */ > uint32_t last_logged_errcode; > + /** Remote instance ID. */ > + uint32_t instance_id; > /** Remote instance UUID */ > struct tt_uuid uuid; > /** Remote URI (string) */ -- Serge Petrenko
next prev parent reply other threads:[~2020-09-04 8:13 UTC|newest] Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-09-03 22:51 [Tarantool-patches] [PATCH v2 00/10] dRaft Vladislav Shpilevoy 2020-09-03 22:51 ` [Tarantool-patches] [PATCH v2 01/10] applier: store instance_id in struct applier Vladislav Shpilevoy 2020-09-04 8:13 ` Serge Petrenko [this message] 2020-09-07 22:54 ` Vladislav Shpilevoy 2020-09-03 22:51 ` [Tarantool-patches] [PATCH v2 10/10] raft: introduce box.info.raft Vladislav Shpilevoy 2020-09-04 11:38 ` Serge Petrenko 2020-09-03 22:51 ` [Tarantool-patches] [PATCH v2 02/10] box: introduce summary RO flag Vladislav Shpilevoy 2020-09-04 8:17 ` Serge Petrenko 2020-09-03 22:51 ` [Tarantool-patches] [PATCH v2 03/10] wal: don't touch box.cfg.wal_dir more than once Vladislav Shpilevoy 2020-09-04 8:20 ` Serge Petrenko 2020-09-03 22:51 ` [Tarantool-patches] [PATCH v2 04/10] replication: track registered replica count Vladislav Shpilevoy 2020-09-04 8:24 ` Serge Petrenko 2020-09-07 22:54 ` Vladislav Shpilevoy 2020-09-07 15:45 ` Sergey Ostanevich 2020-09-07 22:54 ` Vladislav Shpilevoy 2020-09-03 22:51 ` [Tarantool-patches] [PATCH v2 05/10] raft: introduce persistent raft state Vladislav Shpilevoy 2020-09-04 8:59 ` Serge Petrenko 2020-09-03 22:51 ` [Tarantool-patches] [PATCH v2 06/10] raft: introduce box.cfg.raft_* options Vladislav Shpilevoy 2020-09-04 9:07 ` Serge Petrenko 2020-09-07 22:55 ` Vladislav Shpilevoy 2020-09-03 22:51 ` [Tarantool-patches] [PATCH v2 07/10] raft: relay status updates to followers Vladislav Shpilevoy 2020-09-03 22:51 ` [Tarantool-patches] [PATCH v2 08/10] [tosquash] raft: pass source instance_id to raft_process_msg() Vladislav Shpilevoy 2020-09-04 9:22 ` Serge Petrenko 2020-09-03 22:51 ` [Tarantool-patches] [PATCH v2 09/10] raft: introduce state machine Vladislav Shpilevoy 2020-09-04 11:36 ` Serge Petrenko 2020-09-07 22:57 ` Vladislav Shpilevoy 2020-09-09 8:04 ` Serge Petrenko
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=48e523a3-0507-0702-c39d-c1ef367a235a@tarantool.org \ --to=sergepetrenko@tarantool.org \ --cc=gorcunov@gmail.com \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v2 01/10] applier: store instance_id in struct applier' \ /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