From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp61.i.mail.ru (smtp61.i.mail.ru [217.69.128.41]) (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 450BA4696C3 for ; Thu, 23 Apr 2020 12:53:31 +0300 (MSK) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) From: Serge Petrenko In-Reply-To: <20200423094112.GD3072@uranus> Date: Thu, 23 Apr 2020 12:53:30 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <28487782-9C98-432A-95E1-A3583C96A564@tarantool.org> References: <20200422182810.79257-1-sergepetrenko@tarantool.org> <20200423094112.GD3072@uranus> Subject: Re: [Tarantool-patches] [PATCH] applier: follow vclock to the last tx row List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Cyrill Gorcunov Cc: tarantool-patches@dev.tarantool.org, Vladislav Shpilevoy > 23 =D0=B0=D0=BF=D1=80. 2020 =D0=B3., =D0=B2 12:41, Cyrill Gorcunov = =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0=B0): >=20 > On Wed, Apr 22, 2020 at 09:28:10PM +0300, Serge Petrenko wrote: >> Since the introduction of transaction boundaries in replication >> protocol, appliers follow replicaset.applier.vclock to the lsn of the >> first row in an arrived batch. This is enough and doesn't lead to = errors >> when replicating from other instances, respecting transaction = boundaries >> (instances with version 2.1.2 and up). However, if there's a 1.10 >> instance in 2.1.2+ cluster, it sends every single tx row as a = separate >> transaction, breaking the comparison with replicaset.applier.vclock = and >> making the applier apply part of the changes, it has already applied >> when processing a full transaction coming from another 2.x instance. >> Such behaviour leads to ER_TUPLE_FOUND errors in the scenario = described >> above. >> In order to guard from such cases, follow replicaset.applier.vclock = to >> the lsn of the last row in tx. >>=20 >> Closes #4924 >=20 > Serge, can we please put this into code comment itself? Say like > (please check that I didn't miss somthing) > --- > diff --git a/src/box/applier.cc b/src/box/applier.cc > index 68de3c08c..495bc7393 100644 > --- a/src/box/applier.cc > +++ b/src/box/applier.cc > @@ -736,6 +736,7 @@ applier_apply_tx(struct stailq *rows) > { > struct xrow_header *first_row =3D &stailq_first_entry(rows, > struct applier_tx_row, = next)->row; > + struct xrow_header *last_row; > struct replica *replica =3D = replica_by_id(first_row->replica_id); > /* > * In a full mesh topology, the same set of changes > @@ -826,9 +827,16 @@ applier_apply_tx(struct stailq *rows) > if (txn_commit_async(txn) < 0) > goto fail; >=20 > - /* Transaction was sent to journal so promote vclock. */ > - vclock_follow(&replicaset.applier.vclock, > - first_row->replica_id, first_row->lsn); > + /* > + * The transaction was sent to the journal so promote vclock. > + * > + * Use the lsn of the last row here for backward compatibility > + * with 1.10 series where we sent every single tx in a row as > + * a separate transaction. > + */ > + last_row =3D &stailq_last_entry(rows, struct applier_tx_row, = next)->row; > + vclock_follow(&replicaset.applier.vclock, = last_row->replica_id, > + last_row->lsn); > latch_unlock(latch); > return 0; > rollback: Hi! Thanks for the review! I=E2=80=99ve added a slightly different = comment: diff --git a/src/box/applier.cc b/src/box/applier.cc index eb0297f73..42a154a33 100644 --- a/src/box/applier.cc +++ b/src/box/applier.cc @@ -827,7 +827,13 @@ applier_apply_tx(struct stailq *rows) if (txn_commit_async(txn) < 0) goto fail; =20 - /* Transaction was sent to journal so promote vclock. */ + /* + * The transaction was sent to journal so promote vclock. + * + * Use the lsn of the last row to guard from 1.10 + * instances, which send every single tx row as a separate + * transaction. + */ last_row =3D &stailq_last_entry(rows, struct applier_tx_row, = next)->row; vclock_follow(&replicaset.applier.vclock, last_row->replica_id, last_row->lsn); -- Serge Petrenko sergepetrenko@tarantool.org