From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) (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 45D29430D46 for ; Thu, 19 Mar 2020 12:06:50 +0300 (MSK) Received: by mail-lf1-f67.google.com with SMTP id z22so958350lfd.8 for ; Thu, 19 Mar 2020 02:06:50 -0700 (PDT) From: Cyrill Gorcunov Date: Thu, 19 Mar 2020 12:05:32 +0300 Message-Id: <20200319090537.5613-7-gorcunov@gmail.com> In-Reply-To: <20200319090537.5613-1-gorcunov@gmail.com> References: <20200319090537.5613-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v13 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