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 8B4F66EC70; Sat, 12 Jun 2021 01:00:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8B4F66EC70 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1623448825; bh=jKqU41Bn2RCf5ZTSax/5ltsyY1unn30Bcs4juUi71tM=; 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=ryws2YyBK31zkWUvmJCAqV9RDS3zMCKE9Nz6h0DIwKxczk6BzEM2XIjjU4U54KuOC WY+Ax1qyaHQqjLummUJifPA8xY1aE1Ry19vh5OJHhTwgUZlRZYWhANiuiHbGdbx0iq unr49BwQN07lfInhKEe++JBjZf7NzGf5/WSc/Y18= 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 8F4EC6EC7F for ; Sat, 12 Jun 2021 00:56:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8F4EC6EC7F Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1lrp8d-0008JK-Kv; Sat, 12 Jun 2021 00:56:28 +0300 To: tarantool-patches@dev.tarantool.org, gorcunov@gmail.com, sergepetrenko@tarantool.org Date: Fri, 11 Jun 2021 23:56:11 +0200 Message-Id: <3cf8acc10c635d7a7b84ea1869213a2d11cf4ec9.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: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9D5B0DA836B685C54EECC50CDFE52CD8E09EC742E3E75A787182A05F5380850404A9FBDE568D55369DCC7F2FF2795688FCFE63226973FEE74A011865E7585F384 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE76CEA61CADDE926D9B287FD4696A6DC2FA8DF7F3B2552694A4E2F5AFA99E116B42401471946AA11AFEE3A9D0FB4FE0F9922EA870BBF4AACFC8F08D7030A58E5AD1A62830130A00468AEEEE3FBA3A834EE7353EFBB553375668874A2D3FA5089FEBF003033197F4419F6FE61668C570441A471835C12D1D9774AD6D5ED66289B5259CC434672EE6371117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658359CC434672EE6371117882F4460429728AD0CFFFB425014E868A13BD56FB6657E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F79006373BC478629CBEC79DEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C978317387390EF8EF124063EC326E2DBBB914 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8183A4AFAF3EA6BDC44C234C8B12C006B7A1906CDB4DF5A7290C82016AB974E2F3F3D19172D7577D980B1881A6453793CE9C32612AADDFBE061C61BE10805914D3804EBA3D8E7E5B87ABF8C51168CD8EBDB791E6C230873D55CDC48ACC2A39D04F89CDFB48F4795C241BDAD6C7F3747799A X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D343D1F112031EF3D62B6BC69D61C4645BC336D0CFAC42865105C2567B168B0E34884A12042546D14241D7E09C32AA3244C763F4FC18C8575BCE8FF2CBFCE34FA6C60759606DA2E136AFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojQR1NM653rVFPYiWiw8EUBQ== X-Mailru-Sender: 689FA8AB762F73936BC43F508A06382272FCAB0710BF2134BA149E0BD3BAB03E3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH 03/13] journal: make journal_write() set diag on error 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" It used to simply return -1 and set a diag only when OOM happened inside. The caller was forced either to ignore the result or set its own diag regardless of what really happened. The patch makes journal_write() set a correct diag error when it returns -1. The only implementation to change was wal_write_async(). The other implementations always return 0. Part of #6027 --- src/box/applier.cc | 4 +++- src/box/raft.c | 8 +++++--- src/box/txn.c | 14 ++++++++------ src/box/txn_limbo.c | 30 +++++++++++++++++------------- src/box/wal.c | 2 ++ 5 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/box/applier.cc b/src/box/applier.cc index 33181fdbf..60d648795 100644 --- a/src/box/applier.cc +++ b/src/box/applier.cc @@ -835,7 +835,9 @@ apply_synchro_row(struct xrow_header *row) * before trying to commit. But that requires extra steps from the * transactions side, including the async ones. */ - if (journal_write(&entry.base) != 0 || entry.base.res < 0) { + if (journal_write(&entry.base) != 0) + goto err; + if (entry.base.res < 0) { diag_set(ClientError, ER_WAL_IO); goto err; } diff --git a/src/box/raft.c b/src/box/raft.c index 6b52c9876..55dee4cb1 100644 --- a/src/box/raft.c +++ b/src/box/raft.c @@ -307,17 +307,19 @@ box_raft_write(struct raft *raft, const struct raft_msg *msg) * follows this pattern of 'protection'. */ bool cancellable = fiber_set_cancellable(false); - bool ok = (journal_write(entry) == 0 && entry->res >= 0); + bool is_err = journal_write(entry) != 0; fiber_set_cancellable(cancellable); - if (!ok) { + if (is_err) + goto fail; + if (entry->res < 0) { diag_set(ClientError, ER_WAL_IO); - diag_log(); goto fail; } region_truncate(region, svp); return; fail: + diag_log(); /* * XXX: the stub is supposed to be removed once it is defined what to do * when a raft request WAL write fails. diff --git a/src/box/txn.c b/src/box/txn.c index 966dfafdf..761630939 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -847,7 +847,6 @@ txn_commit_try_async(struct txn *txn) fiber_set_txn(fiber(), NULL); if (journal_write_try_async(req) != 0) { fiber_set_txn(fiber(), txn); - diag_set(ClientError, ER_WAL_IO); diag_log(); goto rollback; } @@ -904,12 +903,11 @@ txn_commit(struct txn *txn) } fiber_set_txn(fiber(), NULL); - if (journal_write(req) != 0 || req->res < 0) { - if (txn_has_flag(txn, TXN_WAIT_SYNC)) - txn_limbo_abort(&txn_limbo, limbo_entry); + if (journal_write(req) != 0) + goto rollback_io; + if (req->res < 0) { diag_set(ClientError, ER_WAL_IO); - diag_log(); - goto rollback; + goto rollback_io; } if (txn_has_flag(txn, TXN_WAIT_SYNC)) { if (txn_has_flag(txn, TXN_WAIT_ACK)) { @@ -934,6 +932,10 @@ txn_commit(struct txn *txn) txn_free(txn); return 0; +rollback_io: + diag_log(); + if (txn_has_flag(txn, TXN_WAIT_SYNC)) + txn_limbo_abort(&txn_limbo, limbo_entry); rollback: assert(txn->fiber != NULL); if (!txn_has_flag(txn, TXN_IS_DONE)) { diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c index dae6d2df4..83b86387c 100644 --- a/src/box/txn_limbo.c +++ b/src/box/txn_limbo.c @@ -335,21 +335,25 @@ txn_limbo_write_synchro(struct txn_limbo *limbo, uint16_t type, int64_t lsn, journal_entry_create(entry, 1, xrow_approx_len(&row), journal_entry_fiber_wakeup_cb, fiber()); - if (journal_write(entry) != 0 || entry->res < 0) { + if (journal_write(entry) != 0) + goto fail; + if (entry->res < 0) { diag_set(ClientError, ER_WAL_IO); - diag_log(); - /* - * XXX: the stub is supposed to be removed once it is defined - * what to do when a synchro request WAL write fails. One of - * the possible solutions: log the error, keep the limbo - * queue as is and probably put in rollback mode. Then - * provide a hook to call manually when WAL problems are fixed. - * Or retry automatically with some period. - */ - panic("Could not write a synchro request to WAL: " - "lsn = %lld, type = %s\n", (long long)lsn, - iproto_type_name(type)); + goto fail; } + return; +fail: + diag_log(); + /* + * XXX: the stub is supposed to be removed once it is defined what to do + * when a synchro request WAL write fails. One of the possible + * solutions: log the error, keep the limbo queue as is and probably put + * in rollback mode. Then provide a hook to call manually when WAL + * problems are fixed. Or retry automatically with some period. + */ + panic("Could not write a synchro request to WAL: lsn = %lld, " + "type = %s\n", (long long)lsn, iproto_type_name(type)); + } /** diff --git a/src/box/wal.c b/src/box/wal.c index 5c52142ef..25edbace6 100644 --- a/src/box/wal.c +++ b/src/box/wal.c @@ -1244,6 +1244,7 @@ wal_write_async(struct journal *journal, struct journal_entry *entry) struct wal_writer *writer = (struct wal_writer *) journal; ERROR_INJECT(ERRINJ_WAL_IO, { + diag_set(ClientError, ER_WAL_IO); goto fail; }); @@ -1258,6 +1259,7 @@ wal_write_async(struct journal *journal, struct journal_entry *entry) say_error("Aborting transaction %lld during " "cascading rollback", (long long)vclock_sum(&writer->vclock)); + diag_set(ClientError, ER_CASCADE_ROLLBACK); goto fail; } -- 2.24.3 (Apple Git-128)