From: Vladislav Shpilevoy via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: tarantool-patches@dev.tarantool.org, gorcunov@gmail.com, sergepetrenko@tarantool.org Subject: [Tarantool-patches] [PATCH 10/13] txn: install proper diag errors on txn fail Date: Fri, 11 Jun 2021 23:56:06 +0200 [thread overview] Message-ID: <82c470d34b0e86bbb643c83da236ad07462876d2.1623448465.git.v.shpilevoy@tarantool.org> (raw) In-Reply-To: <cover.1623448465.git.v.shpilevoy@tarantool.org> Previously all journal and txn errors were turned into ER_WAL_IO error code. It led to loss of the real error, which sometimes was absolutely not related to IO. For example, a timeout in the limbo for a synchronous transaction. The patch makes journal/txn errors turn into proper diags. Part of #6027 --- src/box/errcode.h | 1 + src/box/journal.c | 10 +++++++--- src/box/txn.c | 17 ++++++++++++++++- test/box/error.result | 1 + 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/box/errcode.h b/src/box/errcode.h index b143e91d9..49aec4bf6 100644 --- a/src/box/errcode.h +++ b/src/box/errcode.h @@ -277,6 +277,7 @@ struct errcode_record { /*222 */_(ER_QUORUM_WAIT, "Couldn't wait for quorum %d: %s") \ /*223 */_(ER_INTERFERING_PROMOTE, "Instance with replica id %u was promoted first") \ /*224 */_(ER_RAFT_DISABLED, "Elections were turned off while running box.ctl.promote()")\ + /*225 */_(ER_TXN_ROLLBACK, "Transaction was rolled back") \ /* * !IMPORTANT! Please follow instructions at start of the file diff --git a/src/box/journal.c b/src/box/journal.c index 35c99c1c6..32c3e4bd7 100644 --- a/src/box/journal.c +++ b/src/box/journal.c @@ -45,9 +45,13 @@ struct journal_queue journal_queue = { void diag_set_journal_res_detailed(const char *file, unsigned line, int64_t res) { - assert(res < 0 && res != JOURNAL_ENTRY_ERR_UNKNOWN); - (void)res; - diag_set_detailed(file, line, ClientError, ER_WAL_IO); + switch(res) { + case JOURNAL_ENTRY_ERR_IO: + diag_set_detailed(file, line, ClientError, ER_WAL_IO); + return; + } + panic("Journal result code %lld can't be converted to an error " + "at %s:%u", (long long)res, file, line); } struct journal_entry * diff --git a/src/box/txn.c b/src/box/txn.c index 1c1eb15bc..b3819b8f9 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -251,7 +251,22 @@ txn_free(struct txn *txn) void diag_set_txn_sign_detailed(const char *file, unsigned line, int64_t signature) { - return diag_set_journal_res_detailed(file, line, signature); + if (signature >= JOURNAL_ENTRY_ERR_MIN) + return diag_set_journal_res_detailed(file, line, signature); + switch(signature) { + case TXN_SIGNATURE_ROLLBACK: + diag_set_detailed(file, line, ClientError, ER_TXN_ROLLBACK); + return; + case TXN_SIGNATURE_QUORUM_TIMEOUT: + diag_set_detailed(file, line, ClientError, + ER_SYNC_QUORUM_TIMEOUT); + return; + case TXN_SIGNATURE_SYNC_ROLLBACK: + diag_set_detailed(file, line, ClientError, ER_SYNC_ROLLBACK); + return; + } + panic("Transaction signature %lld can't be converted to an error " + "at %s:%u", (long long)signature, file, line); } struct txn * diff --git a/test/box/error.result b/test/box/error.result index 6ef099153..062a90399 100644 --- a/test/box/error.result +++ b/test/box/error.result @@ -443,6 +443,7 @@ t; | 222: box.error.QUORUM_WAIT | 223: box.error.INTERFERING_PROMOTE | 224: box.error.RAFT_DISABLED + | 225: box.error.TXN_ROLLBACK | ... test_run:cmd("setopt delimiter ''"); -- 2.24.3 (Apple Git-128)
next prev parent reply other threads:[~2021-06-11 21:57 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-06-11 21:56 [Tarantool-patches] [PATCH 00/13] Applier rollback reason Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 01/13] error: introduce ER_CASCADE_ROLLBACK Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` Vladislav Shpilevoy via Tarantool-patches [this message] 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 11/13] wal: introduce JOURNAL_ENTRY_ERR_CASCADE Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 12/13] txn: introduce TXN_SIGNATURE_ABORT Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 13/13] txn: stop TXN_SIGNATURE_ABORT override Vladislav Shpilevoy via Tarantool-patches 2021-06-15 13:44 ` Serge Petrenko via Tarantool-patches 2021-06-15 19:34 ` Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 02/13] test: remove replica-applier-rollback.lua Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 03/13] journal: make journal_write() set diag on error Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 04/13] wal: refactor wal_write_to_disk() Vladislav Shpilevoy via Tarantool-patches 2021-06-15 20:46 ` Cyrill Gorcunov via Tarantool-patches 2021-06-16 6:22 ` Vladislav Shpilevoy via Tarantool-patches 2021-06-16 8:02 ` Cyrill Gorcunov via Tarantool-patches 2021-06-16 23:32 ` Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 05/13] diag: introduce diag_set_detailed() Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 06/13] wal: encapsulate ER_WAL_IO Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 07/13] txn: change limbo rollback check in the trigger Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 08/13] journal: introduce proper error codes Vladislav Shpilevoy via Tarantool-patches 2021-06-11 21:56 ` [Tarantool-patches] [PATCH 09/13] txn: assert after WAL write that txn is not done Vladislav Shpilevoy via Tarantool-patches 2021-06-15 13:43 ` [Tarantool-patches] [PATCH 00/13] Applier rollback reason Serge Petrenko via Tarantool-patches 2021-06-16 23:32 ` Vladislav Shpilevoy 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=82c470d34b0e86bbb643c83da236ad07462876d2.1623448465.git.v.shpilevoy@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 10/13] txn: install proper diag errors on txn fail' \ /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