From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: tarantool-patches@dev.tarantool.org, gorcunov@gmail.com Subject: [Tarantool-patches] [PATCH 2/2] txn: single failure point for WAL and TX async commit errors Date: Mon, 20 Jul 2020 22:43:06 +0200 [thread overview] Message-ID: <3701daa1eb82b9d24fdf110b17f8438186d8f897.1595277631.git.v.shpilevoy@tarantool.org> (raw) In-Reply-To: <cover.1595277631.git.v.shpilevoy@tarantool.org> The same as the previous commit, but applied to the async transaction commit (txn_commit_async()). There were 6 failure points. After the patch the failures are handled in one place. Follow up #5146 --- src/box/txn.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/src/box/txn.c b/src/box/txn.c index 375c01f85..bd9fcdbe6 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -711,23 +711,18 @@ txn_commit_async(struct txn *txn) * output to mark this event. */ diag_log(); - txn_rollback(txn); - return -1; + goto rollback; }); - if (txn_prepare(txn) != 0) { - txn_rollback(txn); - return -1; - } + if (txn_prepare(txn) != 0) + goto rollback; if (txn_commit_nop(txn)) return 0; req = txn_journal_entry_new(txn); - if (req == NULL) { - txn_rollback(txn); - return -1; - } + if (req == NULL) + goto rollback; bool is_sync = txn_has_flag(txn, TXN_WAIT_SYNC); struct txn_limbo_entry *limbo_entry; @@ -741,19 +736,16 @@ txn_commit_async(struct txn *txn) struct trigger *trig = region_alloc_object(&txn->region, typeof(*trig), &size); if (trig == NULL) { - txn_rollback(txn); diag_set(OutOfMemory, size, "region_alloc_object", "trig"); - return -1; + goto rollback; } /* 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_rollback(txn); - return -1; - } + if (limbo_entry == NULL) + goto rollback; if (txn_has_flag(txn, TXN_WAIT_ACK)) { int64_t lsn = req->rows[txn->n_applier_rows - 1]->lsn; @@ -779,14 +771,17 @@ txn_commit_async(struct txn *txn) fiber_set_txn(fiber(), NULL); if (journal_write_async(req) != 0) { fiber_set_txn(fiber(), txn); - txn_rollback(txn); - diag_set(ClientError, ER_WAL_IO); diag_log(); - return -1; + goto rollback; } return 0; + +rollback: + assert(txn->fiber == NULL); + txn_rollback(txn); + return -1; } int -- 2.21.1 (Apple Git-122.3)
next prev parent reply other threads:[~2020-07-20 20:43 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-07-20 20:43 [Tarantool-patches] [PATCH 0/2] Qsync crash on WAL write fail Vladislav Shpilevoy 2020-07-20 20:43 ` [Tarantool-patches] [PATCH 1/2] txn: single failure point for WAL and TX commit errors Vladislav Shpilevoy 2020-07-21 8:42 ` Cyrill Gorcunov 2020-07-20 20:43 ` Vladislav Shpilevoy [this message] 2020-07-21 8:43 ` [Tarantool-patches] [PATCH 2/2] txn: single failure point for WAL and TX async " Cyrill Gorcunov 2020-07-20 20:44 ` [Tarantool-patches] [PATCH 0/2] Qsync crash on WAL write fail Vladislav Shpilevoy 2020-07-21 20:25 ` Vladislav Shpilevoy 2020-07-22 10:41 ` Kirill Yukhin 2020-07-22 22:27 ` Vladislav Shpilevoy
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=3701daa1eb82b9d24fdf110b17f8438186d8f897.1595277631.git.v.shpilevoy@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=gorcunov@gmail.com \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 2/2] txn: single failure point for WAL and TX async commit errors' \ /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