[Tarantool-patches] [PATCH 12/14] box/txn: do not use journal_write_async under the hood

Cyrill Gorcunov gorcunov at gmail.com
Wed Feb 19 21:37:11 MSK 2020


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 <gorcunov at gmail.com>
---
 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



More information about the Tarantool-patches mailing list