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 CC774441854 for ; Fri, 20 Mar 2020 11:21:08 +0300 (MSK) Received: by mail-lj1-f194.google.com with SMTP id o10so5443004ljc.8 for ; Fri, 20 Mar 2020 01:21:08 -0700 (PDT) From: Cyrill Gorcunov Date: Fri, 20 Mar 2020 11:19:51 +0300 Message-Id: <20200320081956.30650-7-gorcunov@gmail.com> In-Reply-To: <20200320081956.30650-1-gorcunov@gmail.com> References: <20200320081956.30650-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v15 06/11] 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 journal redesign is complete. Acked-by: Konstantin Osipov 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 6bb1b06ed..7a2a4877e 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -559,6 +559,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) { @@ -567,17 +583,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