[tarantool-patches] [PATCH v2 4/5] Emit NOP if an applier skips row

Vladimir Davydov vdavydov.dev at gmail.com
Mon Jan 28 15:15:40 MSK 2019


On Tue, Jan 22, 2019 at 01:31:12PM +0300, Georgy Kirichenko wrote:
> Fill lsn gaps with NOP rows if applier configured to skip conflicting
> rows. This enforces wal consistency.

The patch may be worthwhile, but the comment sounds very obscure.
What's "wal consistency"? How can the wal become inconsistent without
this patch? Shouldn't there be a test proving this patch is correct?

> 
> Prerequisite #980
> ---
>  src/box/applier.cc | 29 ++++++++++++++++-------------
>  1 file changed, 16 insertions(+), 13 deletions(-)
> 
> diff --git a/src/box/applier.cc b/src/box/applier.cc
> index 148c8ce5a..adbe88679 100644
> --- a/src/box/applier.cc
> +++ b/src/box/applier.cc
> @@ -533,23 +533,26 @@ applier_subscribe(struct applier *applier)
>  						     row.replica_id);
>  			vclock_follow_xrow(&replicaset.applier.vclock, &row);
>  			int res = xstream_write(applier->subscribe_stream, &row);
> -			if (res != 0) {
> -				struct error *e = diag_last_error(diag_get());
> +			struct error *e = diag_last_error(diag_get());
> +			if (res != 0 && e->type == &type_ClientError &&
> +			    box_error_code(e) == ER_TUPLE_FOUND &&
> +			    replication_skip_conflict) {
>  				/**
>  				 * Silently skip ER_TUPLE_FOUND error if such
>  				 * option is set in config.
>  				 */
> -				if (e->type == &type_ClientError &&
> -				    box_error_code(e) == ER_TUPLE_FOUND &&
> -				    replication_skip_conflict)
> -					diag_clear(diag_get());
> -				else {
> -					/* Rollback lsn to have a chance for a retry. */
> -					vclock_set(&replicaset.applier.vclock,
> -						   row.replica_id, old_lsn);
> -					latch_unlock(latch);
> -					diag_raise();
> -				}
> +				diag_clear(diag_get());
> +				row.type = IPROTO_NOP;
> +				row.bodycnt = 0;
> +				res = xstream_write(applier->subscribe_stream,
> +						    &row);

A comment explaining why this is done would be nice to have.

> +			}
> +			if (res != 0) {
> +				/* Rollback lsn to have a chance for a retry. */
> +				vclock_set(&replicaset.applier.vclock,
> +					   row.replica_id, old_lsn);
> +				latch_unlock(latch);
> +				diag_raise();
>  			}
>  		}
>  done:



More information about the Tarantool-patches mailing list