From: Vladimir Davydov <vdavydov.dev@gmail.com> To: Serge Petrenko <sergepetrenko@tarantool.org> Cc: tarantool-patches@freelists.org, Georgy Kirichenko <georgy@tarantool.org> Subject: Re: [PATCH v3/3] replication: handle replication shutdown correctly. Date: Wed, 15 Aug 2018 21:47:58 +0300 [thread overview] Message-ID: <20180815184758.oru4d4nxzgj7ze3p@esperanza> (raw) In-Reply-To: <2FE86AFE-AE17-4AB3-A60B-F7CB487E5F85@tarantool.org> On Wed, Aug 15, 2018 at 07:13:28PM +0300, Serge Petrenko wrote: > diff --git a/src/box/replication.cc b/src/box/replication.cc > index 48956d2ed..083ae6407 100644 > --- a/src/box/replication.cc > +++ b/src/box/replication.cc > @@ -91,13 +91,6 @@ replication_init(void) > latch_create(&replicaset.applier.order_latch); > } > > -void > -replication_free(void) > -{ > - free(replicaset.replica_by_id); > - fiber_cond_destroy(&replicaset.applier.cond); > -} > - > void > replica_check_id(uint32_t replica_id) > { > @@ -242,6 +235,42 @@ replica_clear_applier(struct replica *replica) > trigger_clear(&replica->on_applier_state); > } > > +void > +replication_free(void) > +{ > + struct replica *replica, *next; > + > + replica_hash_foreach_safe(&replicaset.hash, replica, next) { > + if (replica->id == instance_id) { > + replica_hash_remove(&replicaset.hash, replica); > + /* > + * Local replica doesn't have neither applier > + * nor relay, so ignore it. > + */ > + continue; > + } > + if (replica->applier != NULL) { > + replica_clear_applier(replica); > + /* > + * We're exiting, so control won't be passed > + * to appliers and we don't need to stop them. > + */ > + } You don't need this code either. I want this loop to be as simple as /* * <explain why> */ replicaset_foreach(replica) relay_cancel(replica->relay); Then you wouldn't even need to move the definition of replication_free. > + if (replica->id != REPLICA_ID_NIL) { > + /* > + * Relay threads keep sending messages > + * to tx via cbus upon shutdown, which > + * could lead to segfaults. So cancel > + * them. > + */ > + relay_cancel(replica->relay); > + } > + } > + > + free(replicaset.replica_by_id); > + fiber_cond_destroy(&replicaset.applier.cond); > +}
next prev parent reply other threads:[~2018-08-15 18:47 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-08-15 11:03 Serge Petrenko 2018-08-15 13:49 ` Vladimir Davydov 2018-08-15 16:13 ` Serge Petrenko 2018-08-15 18:47 ` Vladimir Davydov [this message] 2018-08-16 6:05 ` [tarantool-patches] " Serge Petrenko 2018-08-16 8:55 ` Vladimir Davydov
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=20180815184758.oru4d4nxzgj7ze3p@esperanza \ --to=vdavydov.dev@gmail.com \ --cc=georgy@tarantool.org \ --cc=sergepetrenko@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH v3/3] replication: handle replication shutdown correctly.' \ /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