[Tarantool-patches] [PATCH 09/14] box/txn: make txn nop processing a separate routine

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


To reuse in sync commits in next patches.

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 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



More information about the Tarantool-patches mailing list