[PATCH] applier: stop sending ACKs if master closed socket

Vladimir Davydov vdavydov.dev at gmail.com
Mon Jan 29 20:19:18 MSK 2018


On Mon, Jan 29, 2018 at 07:03:27PM +0300, Konstantin Osipov wrote:
> * Vladimir Davydov <vdavydov.dev at gmail.com> [18/01/29 18:59]:
> > 
> >   main/107/applierw/ sio.cc:303 !> SystemError writev(2), called on fd 12, aka 127.0.0.1:50852: Broken pipe
> > 
> > To avoid that, let's make the applier writer fiber (the one that sends
> > ACKs) exit immediately if it receives EPIPE error while trying to send
> > an ACK.
> > 
> > Closes #2945
> > ---
> > Branch: gh-2945-applier-dont-send-acks-if-master-closed-socket
> > 
> >  src/box/applier.cc | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/src/box/applier.cc b/src/box/applier.cc
> > index f0073bad..e8907975 100644
> > --- a/src/box/applier.cc
> > +++ b/src/box/applier.cc
> > @@ -118,6 +118,13 @@ applier_writer_f(va_list ap)
> >  			coio_write_xrow(&io, &xrow);
> >  		} catch (SocketError *e) {
> >  			/*
> > +			 * There is no point trying to send ACKs if
> > +			 * the master closed its end - we would only
> > +			 * spam the log - so exit immediately.
> > +			 */
> > +			if (e->get_errno() == EPIPE)
> > +				break;
> > +			/*
> 
> This fix it contradicts the comment below. 
> If the applier ACK fiber got an error, it waits for reconnect.
> It should not send "noisy" acks while this hasn't happened,
> regardless of the type of error. Why is EPIPE special?

When it happens (EPIPE), the applier is still connected to the master,
because there are rows left in the socket. For every row applied, the
applier wakes up the writer (via writer_cond), which makes it send an
ack and consequently log an error as the receiving end (at the master's
side) has been closed.

> 
> >  			 * Do not exit, if there is a network error,
> >  			 * the reader fiber will reconnect for us
> >  			 * and signal our cond afterwards.



More information about the Tarantool-patches mailing list