[Tarantool-patches] [PATCH 11/16] tx: introduce conflict tracker
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Wed Jul 15 02:51:18 MSK 2020
Thanks for the patch!
See 1 comment below.
On 08.07.2020 17:14, Aleksandr Lyapunov wrote:
> ---
> src/box/txn.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> src/box/txn.h | 5 +++
> 2 files changed, 103 insertions(+)
>
> diff --git a/src/box/txn.c b/src/box/txn.c
> index 2bd44a3..b9f1737 100644
> --- a/src/box/txn.c
> +++ b/src/box/txn.c
> @@ -998,3 +1053,46 @@ void
> tx_manager_free()
> {
> }
> +
> +int
> +txm_cause_conflict(struct txn *wreaker, struct txn *victim)
> +{
> + struct tx_conflict_tracker *tracker = NULL;
> + struct rlist *r1 = wreaker->conflict_list.next;
> + struct rlist *r2 = wreaker->conflicted_by_list.next;
> + while (r1 != &wreaker->conflict_list &&
> + r2 != &wreaker->conflicted_by_list) {
> + tracker = rlist_entry(r1, struct tx_conflict_tracker,
> + in_conflict_list);
> + if (tracker->wreaker == wreaker && tracker->victim == victim)
> + break;
> + tracker = rlist_entry(r2, struct tx_conflict_tracker,
> + in_conflicted_by_list);
> + if (tracker->wreaker == wreaker && tracker->victim == victim)
> + break;
> + tracker = NULL;
> + r1 = r1->next;
> + r2 = r2->next;
> + }
> + if (tracker != NULL) {
> + /* Move to the beginning of a list
> + * for a case of subsequent lookups */
> + rlist_del(&tracker->in_conflict_list);
> + rlist_del(&tracker->in_conflicted_by_list);
> + } else {
> + size_t size;
> + tracker = region_alloc_object(&victim->region,
> + struct tx_conflict_tracker,
> + &size);
> + if (tracker == NULL) {
> + diag_set(OutOfMemory, size, "tx region",
> + "conflict_tracker");
> + return -1;
> + }
> + }
> + tracker->wreaker = wreaker;
> + tracker->victim = victim;
Why don't you save anything into the victim? How will it be
removed from the lists if it will commit earlier than 'wreaker'?
More information about the Tarantool-patches
mailing list