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 D4443469719 for ; Wed, 19 Feb 2020 21:39:35 +0300 (MSK) Received: by mail-lj1-f194.google.com with SMTP id n18so1434576ljo.7 for ; Wed, 19 Feb 2020 10:39:35 -0800 (PST) From: Cyrill Gorcunov Date: Wed, 19 Feb 2020 21:37:11 +0300 Message-Id: <20200219183713.17646-13-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 12/14] box/txn: do not use journal_write_async under the hood List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml While there is some code duplication (maybe we should make merge this into txn_prepare?) the idea is to unweave journal_write_async from txn_commit which is synchronous. Signed-off-by: Cyrill Gorcunov --- src/box/txn.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/box/txn.c b/src/box/txn.c index a95c28431..38241c066 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -605,8 +605,27 @@ txn_commit(struct txn *txn) { txn->fiber = fiber(); - if (txn_commit_async(txn) != 0) + if (txn_prepare(txn) != 0) { + txn_rollback(txn); + return -1; + } + + if (txn_complete_nop(txn)) + return 0; + + struct journal_entry *req = txn_entry_new(txn); + if (req == NULL) { + txn_rollback(txn); + return -1; + } + + /* Send the entry to the journal. */ + if (journal_write_async(req) < 0) { + diag_set(ClientError, ER_WAL_IO); + diag_log(); return -1; + } + /* * In case of non-yielding journal the transaction could already * be done and there is nothing to wait in such cases. -- 2.20.1