From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) (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 219B84696C5 for ; Wed, 19 Feb 2020 21:39:01 +0300 (MSK) Received: by mail-lj1-f195.google.com with SMTP id y6so1479457lji.0 for ; Wed, 19 Feb 2020 10:39:01 -0800 (PST) From: Cyrill Gorcunov Date: Wed, 19 Feb 2020 21:37:08 +0300 Message-Id: <20200219183713.17646-10-gorcunov@gmail.com> In-Reply-To: <20200219183713.17646-1-gorcunov@gmail.com> References: <20200219183713.17646-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 09/14] box/txn: make txn nop processing a separate routine List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml To reuse in sync commits in next patches. Signed-off-by: Cyrill Gorcunov --- src/box/txn.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/box/txn.c b/src/box/txn.c index 3a784b18b..a6a0704c8 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -462,6 +462,22 @@ txn_complete(struct txn *txn) } } +/** + * Try to complete transaction early if there is + * nothing to be sent to the journal engine. + */ +static bool +txn_complete_nop(struct txn *txn) +{ + if (txn->n_new_rows + txn->n_applier_rows != 0) + return false; + + txn->signature = 0; + txn_complete(txn); + fiber_set_txn(fiber(), NULL); + return 0; +} + static void txn_entry_complete_cb(struct journal_entry *entry, void *data) { @@ -567,17 +583,9 @@ txn_commit_async(struct txn *txn) return -1; } - /* - * 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); + if (txn_complete_nop(txn)) return 0; - } + return txn_write_to_wal_async(txn); } -- 2.20.1