From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp48.i.mail.ru (smtp48.i.mail.ru [94.100.177.108]) (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 47342469719 for ; Mon, 14 Sep 2020 19:36:14 +0300 (MSK) Date: Mon, 14 Sep 2020 16:36:13 +0000 From: Nikita Pettik Message-ID: <20200914163613.GA23208@tarantool.org> References: <1599560532-27089-1-git-send-email-alyapunov@tarantool.org> <1599560532-27089-7-git-send-email-alyapunov@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1599560532-27089-7-git-send-email-alyapunov@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH v4 06/12] txm: introduce conflict tracker List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Aleksandr Lyapunov Cc: tarantool-patches@dev.tarantool.org 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.