From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 300B26EC57; Sat, 12 Jun 2021 01:02:19 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 300B26EC57 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1623448939; bh=xtlD4hT0995CF/rMuTs2KGpDXAvDAsPvnMQaxYjo0jQ=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=KCVWNgkbvrvmEbJVPBqpE/upUBNBf7sAx9YzQHqCk1vrEYZ1zWZ5dkA0q9bx6M24H /p7OLRVYwG9eScQjFzEEMLQ0qpjwrzSgjiMGlPc8AtjmI48XApVXuk0maRmpKpaXIu fj9vNWTnq7Sc398/k6XKskYQ/FzUi8YIxnnjskaM= Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 7EE4C6F3C9 for ; Sat, 12 Jun 2021 00:56:33 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7EE4C6F3C9 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1lrp8i-0008JK-OB; Sat, 12 Jun 2021 00:56:33 +0300 To: tarantool-patches@dev.tarantool.org, gorcunov@gmail.com, sergepetrenko@tarantool.org Date: Fri, 11 Jun 2021 23:56:14 +0200 Message-Id: <6714c70b53e22b95dc8a33289de5b837de654428.1623448465.git.v.shpilevoy@tarantool.org> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9D5B0DA836B685C546075B3437CB362FF47FF2EE3FBA69D6F182A05F538085040AC0372C709EF9B098CA3D5C8337E50680DA4341459BB0192129D567C8DAE8B14 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE79A02CDD1178524C2EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006376976B91E969631F08638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D81A074AD19A19269BACC32DFD63E99942117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD182CC0D3CB04F14752D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6B1CFA6D474D4A6A4089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8183A4AFAF3EA6BDC44C234C8B12C006B7A1906CDB4DF5A7290FE43BF461E72BB335D30A474AEF6FFFFB1881A6453793CE9C32612AADDFBE061C61BE10805914D3804EBA3D8E7E5B87ABF8C51168CD8EBDB791E6C230873D55CDC48ACC2A39D04F89CDFB48F4795C241BDAD6C7F3747799A X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34AEC7C2AC3C44791DA7544953A5AF3F804EEEDDD249F0C4CA293B7641FB560927567233F38EC36AB61D7E09C32AA3244C3EFA57A1A738F752C1D39B64455CD427795D98D676DD64D0FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojQR1NM653rVF931GLaUb41Q== X-Mailru-Sender: 689FA8AB762F73936BC43F508A0638223B399971CE5658890368B2E5F274958E3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH 06/13] wal: encapsulate ER_WAL_IO X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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 #include +#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)