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 5EAB64696C5 for ; Thu, 5 Mar 2020 15:31:01 +0300 (MSK) Received: by mail-lf1-f67.google.com with SMTP id z9so4493242lfa.2 for ; Thu, 05 Mar 2020 04:31:01 -0800 (PST) From: Cyrill Gorcunov Date: Thu, 5 Mar 2020 15:29:39 +0300 Message-Id: <20200305122943.7324-7-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 06/10] box/txn: unweave txn_commit from txn_commit_async List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml We gonna divergence sync and async code flow thus lets make txn_commit to not use txn_commit_async. Fixes #4031 Signed-off-by: Cyrill Gorcunov --- src/box/txn.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/box/txn.c b/src/box/txn.c index bee43a066..1c0143703 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -604,10 +604,24 @@ txn_commit_async(struct txn *txn) int txn_commit(struct txn *txn) { + int res = -1; + txn->fiber = fiber(); - if (txn_commit_async(txn) != 0) + if (txn_prepare(txn) != 0) { + txn_rollback(txn); + goto out; + } + + if (txn_commit_nop(txn)) { + res = 0; + goto out; + } + + fiber_set_txn(fiber(), NULL); + if (txn_write_to_wal(txn) != 0) return -1; + /* * In case of non-yielding journal the transaction could already * be done and there is nothing to wait in such cases. @@ -617,10 +631,11 @@ txn_commit(struct txn *txn) fiber_yield(); fiber_set_cancellable(cancellable); } - int res = txn->signature >= 0 ? 0 : -1; + res = txn->signature >= 0 ? 0 : -1; if (res != 0) diag_set(ClientError, ER_WAL_IO); +out: /* Synchronous transactions are freed by the calling fiber. */ txn_free(txn); return res; -- 2.20.1