[Tarantool-patches] [PATCH 04/10] box/txn: move setup of txn start to txn_prepare

Cyrill Gorcunov gorcunov at gmail.com
Thu Mar 5 15:29:37 MSK 2020


For unification sake, we will handle nop transactions
via common helper for both sync and async cases.

Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
---
 src/box/txn.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/box/txn.c b/src/box/txn.c
index 9f61303ab..5dd52e6db 100644
--- a/src/box/txn.c
+++ b/src/box/txn.c
@@ -554,6 +554,15 @@ txn_prepare(struct txn *txn)
 	trigger_clear(&txn->fiber_on_stop);
 	if (!txn_has_flag(txn, TXN_CAN_YIELD))
 		trigger_clear(&txn->fiber_on_yield);
+
+	/*
+	 * It is important to set start transaction
+	 * time at the last moment, when everything
+	 * is ready to initiate commit procedure,
+	 * just to be more precise in timings to
+	 * detect long WAL writes.
+	 */
+	txn->start_tm = ev_monotonic_now(loop());
 	return 0;
 }
 
@@ -569,7 +578,6 @@ txn_commit_async(struct txn *txn)
 	 * After this point the transaction must not be used
 	 * so reset the corresponding key in the fiber storage.
 	 */
-	txn->start_tm = ev_monotonic_now(loop());
 	if (txn->n_new_rows + txn->n_applier_rows == 0) {
 		/* Nothing to do. */
 		txn->signature = 0;
-- 
2.20.1



More information about the Tarantool-patches mailing list