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 06/13] wal: encapsulate ER_WAL_IO
Date: Fri, 11 Jun 2021 23:56:14 +0200 [thread overview]
Message-ID: <6714c70b53e22b95dc8a33289de5b837de654428.1623448465.git.v.shpilevoy@tarantool.org> (raw)
In-Reply-To: <cover.1623448465.git.v.shpilevoy@tarantool.org>
ER_WAL_IO is set on any WAL error if it was after journal_write()
success. It is not correct, because there can be plenty of
reasons.
In WAL it could be an actual IO error or a cascading rollback in
progress. When used for transactions, it could be an error related
to synchronous transactions like a timeout, or a persistent
ROLLBACK.
These errors are overridden by ER_WAL_IO. The patch encapsulates
the diag installation for bad journal write and for transaction
rollback.
The next patches are going to introduce more error codes and use
proper ones to install a diag.
Part of #6027
---
src/box/applier.cc | 10 +++++-----
src/box/journal.c | 8 ++++++++
src/box/journal.h | 10 ++++++++++
src/box/raft.c | 2 +-
src/box/txn.c | 8 +++++++-
src/box/txn.h | 10 ++++++++++
src/box/txn_limbo.c | 2 +-
7 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/src/box/applier.cc b/src/box/applier.cc
index 60d648795..3fd71393d 100644
--- a/src/box/applier.cc
+++ b/src/box/applier.cc
@@ -711,7 +711,7 @@ applier_read_tx(struct applier *applier, struct stailq *rows, double timeout)
}
static void
-applier_rollback_by_wal_io(void)
+applier_rollback_by_wal_io(int64_t signature)
{
/*
* Setup shared applier diagnostic area.
@@ -725,7 +725,7 @@ applier_rollback_by_wal_io(void)
* rollback may happen a way later after it was passed to
* the journal engine.
*/
- diag_set(ClientError, ER_WAL_IO);
+ diag_set_txn_sign(signature);
diag_set_error(&replicaset.applier.diag,
diag_last_error(diag_get()));
@@ -747,7 +747,7 @@ applier_txn_rollback_cb(struct trigger *trigger, void *event)
* special handling.
*/
if (txn->signature != TXN_SIGNATURE_SYNC_ROLLBACK)
- applier_rollback_by_wal_io();
+ applier_rollback_by_wal_io(txn->signature);
return 0;
}
@@ -787,7 +787,7 @@ apply_synchro_row_cb(struct journal_entry *entry)
struct synchro_entry *synchro_entry =
(struct synchro_entry *)entry->complete_data;
if (entry->res < 0) {
- applier_rollback_by_wal_io();
+ applier_rollback_by_wal_io(entry->res);
} else {
txn_limbo_process(&txn_limbo, synchro_entry->req);
trigger_run(&replicaset.applier.on_wal_write, NULL);
@@ -838,7 +838,7 @@ apply_synchro_row(struct xrow_header *row)
if (journal_write(&entry.base) != 0)
goto err;
if (entry.base.res < 0) {
- diag_set(ClientError, ER_WAL_IO);
+ diag_set_journal_res(entry.base.res);
goto err;
}
return 0;
diff --git a/src/box/journal.c b/src/box/journal.c
index df491610a..0a1e9932a 100644
--- a/src/box/journal.c
+++ b/src/box/journal.c
@@ -31,6 +31,7 @@
#include "journal.h"
#include <small/region.h>
#include <diag.h>
+#include "error.h"
struct journal *current_journal = NULL;
@@ -41,6 +42,13 @@ struct journal_queue journal_queue = {
.waiter_count = 0,
};
+void
+diag_set_journal_res_detailed(const char *file, unsigned line, int64_t res)
+{
+ (void)res;
+ diag_set_detailed(file, line, ClientError, ER_WAL_IO);
+}
+
struct journal_entry *
journal_entry_new(size_t n_rows, struct region *region,
journal_write_async_f write_async_cb,
diff --git a/src/box/journal.h b/src/box/journal.h
index 4ab7e8afb..01ea60f72 100644
--- a/src/box/journal.h
+++ b/src/box/journal.h
@@ -44,6 +44,16 @@ struct journal_entry;
typedef void (*journal_write_async_f)(struct journal_entry *entry);
+/**
+ * Convert a result of a journal entry write to an error installed into the
+ * current diag.
+ */
+void
+diag_set_journal_res_detailed(const char *file, unsigned line, int64_t res);
+
+#define diag_set_journal_res(res) \
+ diag_set_journal_res_detailed(__FILE__, __LINE__, res)
+
/**
* An entry for an abstract journal.
* Simply put, a write ahead log request.
diff --git a/src/box/raft.c b/src/box/raft.c
index 55dee4cb1..7f787c0c5 100644
--- a/src/box/raft.c
+++ b/src/box/raft.c
@@ -312,7 +312,7 @@ box_raft_write(struct raft *raft, const struct raft_msg *msg)
if (is_err)
goto fail;
if (entry->res < 0) {
- diag_set(ClientError, ER_WAL_IO);
+ diag_set_journal_res(entry->res);
goto fail;
}
diff --git a/src/box/txn.c b/src/box/txn.c
index 761630939..ac11127d3 100644
--- a/src/box/txn.c
+++ b/src/box/txn.c
@@ -248,6 +248,12 @@ txn_free(struct txn *txn)
stailq_add(&txn_cache, &txn->in_txn_cache);
}
+void
+diag_set_txn_sign_detailed(const char *file, unsigned line, int64_t signature)
+{
+ return diag_set_journal_res_detailed(file, line, signature);
+}
+
struct txn *
txn_begin(void)
{
@@ -906,7 +912,7 @@ txn_commit(struct txn *txn)
if (journal_write(req) != 0)
goto rollback_io;
if (req->res < 0) {
- diag_set(ClientError, ER_WAL_IO);
+ diag_set_journal_res(req->res);
goto rollback_io;
}
if (txn_has_flag(txn, TXN_WAIT_SYNC)) {
diff --git a/src/box/txn.h b/src/box/txn.h
index a06aaea23..d51761bc9 100644
--- a/src/box/txn.h
+++ b/src/box/txn.h
@@ -123,6 +123,16 @@ enum {
TXN_SIGNATURE_SYNC_ROLLBACK = -3,
};
+/**
+ * Convert a result of a transaction execution to an error installed into the
+ * current diag.
+ */
+void
+diag_set_txn_sign_detailed(const char *file, unsigned line, int64_t signature);
+
+#define diag_set_txn_sign(signature) \
+ diag_set_txn_sign_detailed(__FILE__, __LINE__, signature)
+
/**
* Status of a transaction.
*/
diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c
index 83b86387c..b03c71514 100644
--- a/src/box/txn_limbo.c
+++ b/src/box/txn_limbo.c
@@ -338,7 +338,7 @@ txn_limbo_write_synchro(struct txn_limbo *limbo, uint16_t type, int64_t lsn,
if (journal_write(entry) != 0)
goto fail;
if (entry->res < 0) {
- diag_set(ClientError, ER_WAL_IO);
+ diag_set_journal_res(entry->res);
goto fail;
}
return;
--
2.24.3 (Apple Git-128)
next prev parent reply other threads:[~2021-06-11 22:02 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 ` [Tarantool-patches] [PATCH 10/13] txn: install proper diag errors on txn fail Vladislav Shpilevoy via Tarantool-patches
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 ` Vladislav Shpilevoy via Tarantool-patches [this message]
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=6714c70b53e22b95dc8a33289de5b837de654428.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 06/13] wal: encapsulate ER_WAL_IO' \
/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