From: Serge Petrenko via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: v.shpilevoy@tarantool.org, gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH 1/3] box: make txn reference the limbo entry Date: Thu, 20 May 2021 12:02:34 +0300 [thread overview] Message-ID: <afc092b42e62c82a3a2c0dce6c0062418e0af651.1621501007.git.sergepetrenko@tarantool.org> (raw) In-Reply-To: <cover.1621501007.git.sergepetrenko@tarantool.org> When a transaction is synchronous it has the same lifespan as the corresponding txn limbo entry. Moreover, txn limbo entry is already used (and will be used more extensively) in some triggers where struct txn is passed by default. Avoid passing the limbo entry to triggers explicitly by referencing it in struct txn. Prerequisite #6032 --- src/box/txn.c | 25 +++++++++++-------------- src/box/txn.h | 2 ++ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/box/txn.c b/src/box/txn.c index 1d42c9113..1fa3e4367 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -765,12 +765,12 @@ static int txn_limbo_on_rollback(struct trigger *trig, void *event) { (void) event; + (void) trig; struct txn *txn = (struct txn *) event; /* Check whether limbo has performed the cleanup. */ if (txn->signature != TXN_SIGNATURE_ROLLBACK) return 0; - struct txn_limbo_entry *entry = (struct txn_limbo_entry *) trig->data; - txn_limbo_abort(&txn_limbo, entry); + txn_limbo_abort(&txn_limbo, txn->limbo_entry); return 0; } @@ -801,7 +801,6 @@ txn_commit_try_async(struct txn *txn) goto rollback; bool is_sync = txn_has_flag(txn, TXN_WAIT_SYNC); - struct txn_limbo_entry *limbo_entry; if (is_sync) { /* * We'll need this trigger for sync transactions later, @@ -819,8 +818,8 @@ txn_commit_try_async(struct txn *txn) /* See txn_commit(). */ uint32_t origin_id = req->rows[0]->replica_id; - limbo_entry = txn_limbo_append(&txn_limbo, origin_id, txn); - if (limbo_entry == NULL) + txn->limbo_entry = txn_limbo_append(&txn_limbo, origin_id, txn); + if (txn->limbo_entry == NULL) goto rollback; if (txn_has_flag(txn, TXN_WAIT_ACK)) { @@ -832,15 +831,14 @@ txn_commit_try_async(struct txn *txn) * assignment to let the limbo rule this * out. */ - txn_limbo_assign_lsn(&txn_limbo, limbo_entry, lsn); + txn_limbo_assign_lsn(&txn_limbo, txn->limbo_entry, lsn); } /* * Set a trigger to abort waiting for confirm on * WAL write failure. */ - trigger_create(trig, txn_limbo_on_rollback, - limbo_entry, NULL); + trigger_create(trig, txn_limbo_on_rollback, NULL, NULL); txn_on_rollback(txn, trig); } @@ -864,7 +862,6 @@ int txn_commit(struct txn *txn) { struct journal_entry *req; - struct txn_limbo_entry *limbo_entry = NULL; txn->fiber = fiber(); @@ -893,15 +890,15 @@ txn_commit(struct txn *txn) * After WAL write nothing should fail, even OOM * wouldn't be acceptable. */ - limbo_entry = txn_limbo_append(&txn_limbo, origin_id, txn); - if (limbo_entry == NULL) + txn->limbo_entry = txn_limbo_append(&txn_limbo, origin_id, txn); + if (txn->limbo_entry == NULL) goto rollback; } fiber_set_txn(fiber(), NULL); if (journal_write(req) != 0 || req->res < 0) { if (is_sync) - txn_limbo_abort(&txn_limbo, limbo_entry); + txn_limbo_abort(&txn_limbo, txn->limbo_entry); diag_set(ClientError, ER_WAL_IO); diag_log(); goto rollback; @@ -914,12 +911,12 @@ txn_commit(struct txn *txn) * blocking commit is used by local * transactions only. */ - txn_limbo_assign_local_lsn(&txn_limbo, limbo_entry, + txn_limbo_assign_local_lsn(&txn_limbo, txn->limbo_entry, lsn); /* Local WAL write is a first 'ACK'. */ txn_limbo_ack(&txn_limbo, txn_limbo.owner_id, lsn); } - if (txn_limbo_wait_complete(&txn_limbo, limbo_entry) < 0) + if (txn_limbo_wait_complete(&txn_limbo, txn->limbo_entry) < 0) goto rollback; } assert(txn_has_flag(txn, TXN_IS_DONE)); diff --git a/src/box/txn.h b/src/box/txn.h index a06aaea23..6b16372f4 100644 --- a/src/box/txn.h +++ b/src/box/txn.h @@ -349,6 +349,8 @@ struct txn { void *engine_tx; /* A fiber to wake up when transaction is finished. */ struct fiber *fiber; + /** A limbo entry associated with this transaction, if any. */ + struct txn_limbo_entry *limbo_entry; /** Timestampt of entry write start. */ double start_tm; /** -- 2.30.1 (Apple Git-130)
next prev parent reply other threads:[~2021-05-20 9:03 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-20 9:02 [Tarantool-patches] [PATCH 0/3] fix assertion failure in box.ctl.promote() Serge Petrenko via Tarantool-patches 2021-05-20 9:02 ` Serge Petrenko via Tarantool-patches [this message] 2021-05-20 9:02 ` [Tarantool-patches] [PATCH 2/3] txn_limbo: move lsn assignment to journal completion callback Serge Petrenko via Tarantool-patches 2021-05-20 9:02 ` [Tarantool-patches] [PATCH 3/3] box: fix an assertion failure in box.ctl.promote() Serge Petrenko via Tarantool-patches 2021-05-23 12:18 ` Vladislav Shpilevoy via Tarantool-patches 2021-05-25 10:39 ` Serge Petrenko via Tarantool-patches
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=afc092b42e62c82a3a2c0dce6c0062418e0af651.1621501007.git.sergepetrenko@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=gorcunov@gmail.com \ --cc=sergepetrenko@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 1/3] box: make txn reference the limbo entry' \ /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