From: imeevma@tarantool.org To: korablev@tarantool.org, tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org Subject: [tarantool-patches] [PATCH v8 1/3] box: factor fiber_gc out of txn_commit Date: Mon, 29 Oct 2018 20:33:21 +0300 [thread overview] Message-ID: <bcd32c9ee07f365efe142414f5456e34b7ae7bbb.1540832830.git.imeevma@gmail.com> (raw) In-Reply-To: <cover.1540832830.git.imeevma@gmail.com> Now txn_commit is judge, jury and executioner. It both commits or rollbacks data, and collects it calling fiber_gc, which destroys the region. But SQL wants to use some transactional data after commit. It is autogenerated identifiers - a list of sequence values generated for autoincrement columns and explicit sequence:next() calls. It is possible to store the list on malloced mem inside Vdbe, but it complicates deallocation. Much more convenient to store all transactional data on the transaction memory region, so it would be freed together with fiber_gc. After this patch applied, Vdbe takes care of txn memory deallocation in a finalizer routine. Between commit and finalization transactional data can be serialized wherever. Needed for #2618 --- Issue: https://github.com/tarantool/tarantool/issues/2618 Branch: https://github.com/tarantool/tarantool/tree/imeevma/gh-2618-return-all-generated-ids src/box/txn.c | 13 ++++++++----- src/box/vy_scheduler.c | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/box/txn.c b/src/box/txn.c index 617ceb8..9bcc672 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -250,8 +250,11 @@ txn_commit_stmt(struct txn *txn, struct request *request) goto fail; } --txn->in_sub_stmt; - if (txn->is_autocommit && txn->in_sub_stmt == 0) - return txn_commit(txn); + if (txn->is_autocommit && txn->in_sub_stmt == 0) { + int rc = txn_commit(txn); + fiber_gc(); + return rc; + } return 0; fail: txn_rollback_stmt(); @@ -354,8 +357,6 @@ txn_commit(struct txn *txn) txn_stmt_unref_tuples(stmt); TRASH(txn); - /** Free volatile txn memory. */ - fiber_gc(); fiber_set_txn(fiber(), NULL); return 0; fail: @@ -463,7 +464,9 @@ box_txn_commit() diag_set(ClientError, ER_COMMIT_IN_SUB_STMT); return -1; } - return txn_commit(txn); + int rc = txn_commit(txn); + fiber_gc(); + return rc; } int diff --git a/src/box/vy_scheduler.c b/src/box/vy_scheduler.c index eab3f6c..4a46243 100644 --- a/src/box/vy_scheduler.c +++ b/src/box/vy_scheduler.c @@ -886,7 +886,7 @@ vy_deferred_delete_batch_process_f(struct cmsg *cmsg) if (txn_commit(txn) != 0) goto fail; - + fiber_gc(); return; fail: batch->is_failed = true; -- 2.7.4
next prev parent reply other threads:[~2018-10-29 17:33 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-10-29 17:33 [tarantool-patches] [PATCH v8 0/3] sql: return all generated ids via IPROTO imeevma 2018-10-29 17:33 ` imeevma [this message] 2018-10-30 14:30 ` [tarantool-patches] Re: [PATCH v8 1/3] box: factor fiber_gc out of txn_commit n.pettik 2018-10-30 19:15 ` Vladislav Shpilevoy 2018-10-30 20:03 ` Vladislav Shpilevoy 2018-10-30 20:06 ` Vladislav Shpilevoy 2018-10-30 21:32 ` Vladislav Shpilevoy 2018-10-30 23:08 ` n.pettik 2018-10-31 9:18 ` Vladislav Shpilevoy 2018-10-31 9:30 ` n.pettik 2018-10-29 17:33 ` [tarantool-patches] [PATCH v8 2/3] sql: return all generated ids via IPROTO imeevma 2018-10-30 14:30 ` [tarantool-patches] " n.pettik 2018-11-02 18:52 ` Imeev Mergen 2018-11-09 7:51 ` n.pettik 2018-10-29 17:33 ` [tarantool-patches] [PATCH v8 3/3] sql: remove psql_txn from Vdbe imeevma 2018-10-30 14:30 ` [tarantool-patches] " n.pettik 2018-10-30 19:41 ` Vladislav Shpilevoy 2018-11-09 8:02 ` [tarantool-patches] Re: [PATCH v8 0/3] sql: return all generated ids via IPROTO Kirill Yukhin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bcd32c9ee07f365efe142414f5456e34b7ae7bbb.1540832830.git.imeevma@gmail.com \ --to=imeevma@tarantool.org \ --cc=korablev@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH v8 1/3] box: factor fiber_gc out of txn_commit' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox