[Tarantool-patches] [PATCH v4 06/12] txm: introduce conflict tracker

Nikita Pettik korablev at tarantool.org
Mon Sep 14 19:36:13 MSK 2020


On 08 Sep 13:22, Aleksandr Lyapunov wrote:
> +/**
> + * Handle conflict when @breaker transaction is prepared.
> + * The conflict is happened if @victim have read something that @breaker
> + * overwrites.
> + * If @victim is read-only or haven't made any changes, it should be send
> + * to read view, in which is will not see @breaker.
> + * Otherwise @vistim must be marked as conflicted.
> + */

Duplicated comment: it is already placed in memtx_tx.h

> +void
> +memtx_tx_handle_conflict(struct txn *breaker, struct txn *victim)
> +{
> +	assert(breaker->psn != 0);
> +	if (victim->status != TXN_INPROGRESS) {
> +		/* Was conflicted by somebody else. */
> +		return;
> +	}
> +}
> diff --git a/src/box/memtx_tx.h b/src/box/memtx_tx.h
> index fb2cb4d..6143a22 100644
> --- a/src/box/memtx_tx.h
> +++ b/src/box/memtx_tx.h
>  
> +/**
> + * Notify TX manager that if transaction @breaker is committed then the
> + * transaction @victim must be aborted due to conflict.
> + * For example: there's two rw transaction in progress, one have read
> + * some value while the second is about to overwrite it. If the second
> + * is committed first, the first must be aborted.
> + * @return 0 on success, -1 on memory error.
> + */

I'd a bit expose comment:

diff --git a/src/box/memtx_tx.h b/src/box/memtx_tx.h
index 2ebca715d..8307e1ee7 100644
--- a/src/box/memtx_tx.h
+++ b/src/box/memtx_tx.h
@@ -193,7 +193,10 @@ memtx_tx_manager_free();
 
 /**
  * Notify TX manager that if transaction @breaker is committed then the
- * transaction @victim must be aborted due to conflict.
+ * transaction @victim must be aborted due to conflict. It is achieved
+ * by adding corresponding entry (of tx_conflict_tracker type) to @a breaker
+ * conflict list. In case there's already such entry, then move it to the head
+ * of the list in order to optimize next invocations of this function.
  * For example: there's two rw transaction in progress, one have read
  * some value while the second is about to overwrite it. If the second
  * is committed first, the first must be aborted.

Also, as Vlad always notice, in doxygen conversion variable referring
starts from @: @a breaker, @a victim etc.

The rest in this and previous patches LGTM.



More information about the Tarantool-patches mailing list