From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp43.i.mail.ru (smtp43.i.mail.ru [94.100.177.103]) (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 26C3D445320 for ; Wed, 15 Jul 2020 02:51:20 +0300 (MSK) References: <1594221263-6228-1-git-send-email-alyapunov@tarantool.org> <1594221263-6228-12-git-send-email-alyapunov@tarantool.org> From: Vladislav Shpilevoy Message-ID: <198d4c8b-0e6b-9cd0-1d80-8d40f6c68081@tarantool.org> Date: Wed, 15 Jul 2020 01:51:18 +0200 MIME-Version: 1.0 In-Reply-To: <1594221263-6228-12-git-send-email-alyapunov@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH 11/16] tx: introduce conflict tracker List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Aleksandr Lyapunov , tarantool-patches@dev.tarantool.org 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'?