[Tarantool-patches] [PATCH v7 5/8] applier: factor out latch locking

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sat Aug 15 18:04:32 MSK 2020


Thanks for the patch!

On 14.08.2020 23:14, Cyrill Gorcunov wrote:
> We will need to reuse this helpers.
> 
> Part-of #5129
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
> ---
>  src/box/applier.cc | 43 +++++++++++++++++++++++++++++--------------
>  1 file changed, 29 insertions(+), 14 deletions(-)
> 
> diff --git a/src/box/applier.cc b/src/box/applier.cc
> index 98fb87375..60689f6d3 100644
> --- a/src/box/applier.cc
> +++ b/src/box/applier.cc
> @@ -799,6 +799,29 @@ applier_txn_wal_write_cb(struct trigger *trigger, void *event)
>  	return 0;
>  }
>  
> +/*
> + * In a full mesh topology, the same set of changes
> + * may arrive via two concurrently running appliers.
> + * Hence we need a latch to strictly order all changes
> + * that belong to the same server id.
> + */
> +static inline struct latch *
> +applier_lock(uint32_t replica_id)
> +{
> +	struct replica *replica = replica_by_id(replica_id);
> +	struct latch *latch = (replica ? &replica->order_latch :

We usually use != NULL to check if a pointer is not NULL. To emphasize
it is not a boolean variable in the code.

> +			       &replicaset.applier.order_latch);
> +	latch_lock(latch);
> +	return latch;
> +}


More information about the Tarantool-patches mailing list