From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 2AC99431780 for ; Thu, 27 Aug 2020 23:36:09 +0300 (MSK) References: From: Vladislav Shpilevoy Message-ID: <82f89c29-2cce-4a5d-9698-0a240f4d263c@tarantool.org> Date: Thu, 27 Aug 2020 22:36:07 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [RAFT 02/10] raft: relay status updates to followers List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Serge Petrenko , gorcunov@gmail.com, sergos@tarantool.org Cc: tarantool-patches@dev.tarantool.org Hi! Thanks for the patch! > diff --git a/src/box/relay.cc b/src/box/relay.cc > index a7843a8c2..be252cad1 100644 > --- a/src/box/relay.cc > +++ b/src/box/relay.cc > @@ -773,13 +774,40 @@ relay_send_initial_join_row(struct xstream *stream, struct xrow_header *row) > relay_send(relay, row); > } > > +static void > +relay_send_raft(struct relay *relay, struct raft_request *req) > +{ > + struct xrow_header packet; > + xrow_encode_raft(&packet, &fiber()->gc, req); > + relay_send(relay, &packet); > +} > + > +static void > +relay_send_raft_msg(struct cmsg *msg) > +{ > + struct raft_broadcast_msg *raft_msg = (struct raft_broadcast_msg *)msg; > + struct relay *relay = container_of(msg->route[0].pipe, struct relay, > + tx_pipe); > + relay_send_raft(relay, &raft_msg->req); > +} > + > +void > +relay_push_raft_msg(struct relay *relay, struct cmsg *msg, > + struct cmsg_hop *route) > +{ > + route[0].f = relay_send_raft_msg; > + route[0].pipe = &relay->tx_pipe; > + route[1].f = raft_free_msg; > + route[1].pipe = NULL; > + cmsg_init(msg, route); > + cpipe_push(&relay->relay_pipe, msg); > +} > + > /** Send a single row to the client. */ > static void > relay_send_row(struct xstream *stream, struct xrow_header *packet) > { > struct relay *relay = container_of(stream, struct relay, stream); > - assert(iproto_type_is_dml(packet->type) || > - iproto_type_is_synchro_request(packet->type)); > if (packet->group_id == GROUP_LOCAL) { > /* > * We do not relay replica-local rows to other > @@ -796,6 +824,8 @@ relay_send_row(struct xstream *stream, struct xrow_header *packet) > packet->group_id = GROUP_DEFAULT; > packet->bodycnt = 0; > } > + assert(iproto_type_is_dml(packet->type) || > + iproto_type_is_synchro_request(packet->type)); Why did you move this check, if Raft uses relay_send() anyway? Not relay_send_row(). > /* Check if the rows from the instance are filtered. */ > if ((1 << packet->replica_id & relay->id_filter) != 0) > return;