* [tarantool-patches] [PATCH v2] txn: factor fiber_gc out of txn_rollback
@ 2019-03-11 11:56 Georgy Kirichenko
2019-03-11 12:27 ` Vladimir Davydov
0 siblings, 1 reply; 3+ messages in thread
From: Georgy Kirichenko @ 2019-03-11 11:56 UTC (permalink / raw)
To: tarantool-patches; +Cc: Georgy Kirichenko
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [tarantool-patches] [PATCH v2] txn: factor fiber_gc out of txn_rollback
2019-03-11 11:56 [tarantool-patches] [PATCH v2] txn: factor fiber_gc out of txn_rollback Georgy Kirichenko
@ 2019-03-11 12:27 ` Vladimir Davydov
2019-03-11 14:21 ` [tarantool-patches] " Konstantin Osipov
0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Davydov @ 2019-03-11 12:27 UTC (permalink / raw)
To: Georgy Kirichenko; +Cc: tarantool-patches
On Mon, Mar 11, 2019 at 02:56:31PM +0300, Georgy Kirichenko wrote:
> 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;
> }
Run this
tarantool> for i = 1, 1000000 do pcall(box.space._schema.insert, box.space._schema, {'max_id'}) end
and see RSS grow.
I think you should also free memory on txn_rollback_stmt.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tarantool-patches] Re: [PATCH v2] txn: factor fiber_gc out of txn_rollback
2019-03-11 12:27 ` Vladimir Davydov
@ 2019-03-11 14:21 ` Konstantin Osipov
0 siblings, 0 replies; 3+ messages in thread
From: Konstantin Osipov @ 2019-03-11 14:21 UTC (permalink / raw)
To: tarantool-patches
* Vladimir Davydov <vdavydov.dev@gmail.com> [19/03/11 15:31]:
Maybe we find a way to drop this patch altogether?
> On Mon, Mar 11, 2019 at 02:56:31PM +0300, Georgy Kirichenko wrote:
> > 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;
> > }
>
> Run this
>
> tarantool> for i = 1, 1000000 do pcall(box.space._schema.insert, box.space._schema, {'max_id'}) end
>
> and see RSS grow.
>
> I think you should also free memory on txn_rollback_stmt.
--
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-03-11 14:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-11 11:56 [tarantool-patches] [PATCH v2] txn: factor fiber_gc out of txn_rollback Georgy Kirichenko
2019-03-11 12:27 ` Vladimir Davydov
2019-03-11 14:21 ` [tarantool-patches] " Konstantin Osipov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox