[tarantool-patches] [PATCH v2] txn: factor fiber_gc out of txn_rollback

Georgy Kirichenko georgy at tarantool.org
Mon Mar 11 14:56:31 MSK 2019


In some cases we want to retry an operation after possible error leading
to txn_rollback so we shouldn't clear fiber gc memory in such cases.
Also it is consistent with txn_commit that doesn't clear gc memory.

Changes in v2:
 * add fiber_gc after txn_rollback invocation.

Follow-up
  77fa1736dbb9 box: factor fiber_gc out of txn_commit

Branch: https://github.com/tarantool/tarantool/tree/g.kirichenko/gh-2618-txn-rollback-gc-follow-up
---
 src/box/call.c         | 4 ++++
 src/box/txn.c          | 4 ++--
 src/box/vy_scheduler.c | 1 +
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/box/call.c b/src/box/call.c
index b9750c5f3..639b66610 100644
--- a/src/box/call.c
+++ b/src/box/call.c
@@ -209,12 +209,14 @@ box_process_call(struct call_request *request, struct port *port)
 
 	if (rc != 0) {
 		txn_rollback();
+		fiber_gc();
 		return -1;
 	}
 
 	if (in_txn()) {
 		diag_set(ClientError, ER_FUNCTION_TX_ACTIVE);
 		txn_rollback();
+		fiber_gc();
 		return -1;
 	}
 
@@ -230,12 +232,14 @@ box_process_eval(struct call_request *request, struct port *port)
 		return -1;
 	if (box_lua_eval(request, port) != 0) {
 		txn_rollback();
+		fiber_gc();
 		return -1;
 	}
 
 	if (in_txn()) {
 		diag_set(ClientError, ER_FUNCTION_TX_ACTIVE);
 		txn_rollback();
+		fiber_gc();
 		return -1;
 	}
 
diff --git a/src/box/txn.c b/src/box/txn.c
index 7900fb3ab..1f488bbcc 100644
--- a/src/box/txn.c
+++ b/src/box/txn.c
@@ -399,8 +399,6 @@ txn_rollback()
 		txn_stmt_unref_tuples(stmt);
 
 	TRASH(txn);
-	/** Free volatile txn memory. */
-	fiber_gc();
 	fiber_set_txn(fiber(), NULL);
 }
 
@@ -480,6 +478,8 @@ box_txn_rollback()
 		return -1;
 	}
 	txn_rollback(); /* doesn't throw */
+	/** Free volatile txn memory. */
+	fiber_gc();
 	return 0;
 }
 
diff --git a/src/box/vy_scheduler.c b/src/box/vy_scheduler.c
index 92d407808..1e8210fe6 100644
--- a/src/box/vy_scheduler.c
+++ b/src/box/vy_scheduler.c
@@ -901,6 +901,7 @@ fail:
 	batch->is_failed = true;
 	diag_move(diag_get(), &batch->diag);
 	txn_rollback();
+	fiber_gc();
 }
 
 /**
-- 
2.21.0





More information about the Tarantool-patches mailing list