From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 9DEC34696C3 for ; Thu, 5 Mar 2020 15:30:48 +0300 (MSK) Received: by mail-lj1-f194.google.com with SMTP id w1so5857876ljh.5 for ; Thu, 05 Mar 2020 04:30:48 -0800 (PST) From: Cyrill Gorcunov Date: Thu, 5 Mar 2020 15:29:38 +0300 Message-Id: <20200305122943.7324-6-gorcunov@gmail.com> In-Reply-To: <20200305122943.7324-1-gorcunov@gmail.com> References: <20200305122943.7324-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 05/10] box/txn: add txn_commit_nop helper List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml To reuse in sync trancastion once joural redesign is complete. Signed-off-by: Cyrill Gorcunov --- src/box/txn.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/box/txn.c b/src/box/txn.c index 5dd52e6db..bee43a066 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -566,6 +566,22 @@ txn_prepare(struct txn *txn) return 0; } +/** + * Complete transaction early if it is barely nop. + */ +static bool +txn_commit_nop(struct txn *txn) +{ + if (txn->n_new_rows + txn->n_applier_rows == 0) { + txn->signature = 0; + txn_complete(txn); + fiber_set_txn(fiber(), NULL); + return true; + } + + return false; +} + int txn_commit_async(struct txn *txn) { @@ -574,17 +590,13 @@ txn_commit_async(struct txn *txn) return -1; } + if (txn_commit_nop(txn)) + return 0; + /* * After this point the transaction must not be used * so reset the corresponding key in the fiber storage. */ - if (txn->n_new_rows + txn->n_applier_rows == 0) { - /* Nothing to do. */ - txn->signature = 0; - txn_complete(txn); - fiber_set_txn(fiber(), NULL); - return 0; - } fiber_set_txn(fiber(), NULL); return txn_write_to_wal(txn); } -- 2.20.1