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 2B47A6F3F1; Sat, 12 Jun 2021 00:57:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 2B47A6F3F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1623448677; bh=1zaVJu0H1dRGqzEz6+LUJDJ9dLDjvrgCO6NodQjoDRw=; 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=vQ8yg/5cUvwG7p+6nY9z8Dh5omhNEBXxhKb/GRIi5iWAqWjuIGQQRvkXCa3kJB9nS OpSza5sVG8Vociw+lWNdUibDuX3H8BErcQawUc+G1nfEYLbFFExQ77hcNdXqefJs+N 0Euju5bBtMp9539UcQ9uLw045nZUP2wZDAA3BfCo= 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 DC1B86EC6E for ; Sat, 12 Jun 2021 00:56:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DC1B86EC6E Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1lrp8X-0008JK-OC; Sat, 12 Jun 2021 00:56:22 +0300 To: tarantool-patches@dev.tarantool.org, gorcunov@gmail.com, sergepetrenko@tarantool.org Date: Fri, 11 Jun 2021 23:56:07 +0200 Message-Id: <1fa72b7ab80f4375dab72b0c0fd9a1b86b1fb426.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: 4F1203BC0FB41BD9D5B0DA836B685C546075B3437CB362FF47FF2EE3FBA69D6F182A05F53808504025E334C15C2162708CA3D5C8337E5068A29A2D8A4A14F710400879E37F90E024 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7AC4684DF4EC4B256EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637279A5203CF71F5518638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8108DF5364FB48EBFA48FC2AB2F05450E117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8B2EE5AD8F952D28FBA471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7CFA80D66F452D417A43847C11F186F3C59DAA53EE0834AAEE X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C978317387390EF8EF12408955918E15BC64BA X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8183A4AFAF3EA6BDC44C234C8B12C006B7A1906CDB4DF5A7290F58537883E1360FB1374D2A01CB4A744B1881A6453793CE9C32612AADDFBE061C61BE10805914D3804EBA3D8E7E5B87ABF8C51168CD8EBDB791E6C230873D55CDC48ACC2A39D04F89CDFB48F4795C241BDAD6C7F3747799A X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34E9B0C12ABED551377B598D8B56B293DC00948968AA8CF3C495A5A991C1CAEB877639BBA4D30638841D7E09C32AA3244C2E206494AB24AAA3C1D39B64455CD42795A9E0DC41E9A4CFFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojQR1NM653rVH9Lad0ycAqMQ== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822DC4DC54D0DA1A0D3E4F2CD7D1D54A08E3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH 11/13] wal: introduce JOURNAL_ENTRY_ERR_CASCADE 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" A transaction in WAL thread could be rolled back not only due to an IO error. But also if there was a cascading rollback in progress. The patch makes such case use a special error code turned into its own diag when it reaches the TX thread. Usage of ER_WAL_IO wasn't correct here. Part of #6027 --- src/box/journal.c | 3 +++ src/box/journal.h | 5 +++++ src/box/txn.h | 1 + src/box/wal.c | 17 ++++++++++++++--- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/box/journal.c b/src/box/journal.c index 32c3e4bd7..7de149080 100644 --- a/src/box/journal.c +++ b/src/box/journal.c @@ -49,6 +49,9 @@ diag_set_journal_res_detailed(const char *file, unsigned line, int64_t res) case JOURNAL_ENTRY_ERR_IO: diag_set_detailed(file, line, ClientError, ER_WAL_IO); return; + case JOURNAL_ENTRY_ERR_CASCADE: + diag_set_detailed(file, line, ClientError, ER_CASCADE_ROLLBACK); + return; } panic("Journal result code %lld can't be converted to an error " "at %s:%u", (long long)res, file, line); diff --git a/src/box/journal.h b/src/box/journal.h index 18767176e..857245779 100644 --- a/src/box/journal.h +++ b/src/box/journal.h @@ -49,6 +49,11 @@ enum { JOURNAL_ENTRY_ERR_UNKNOWN = -1, /** Tried to be written, but something happened related to IO. */ JOURNAL_ENTRY_ERR_IO = -2, + /** + * Rollback because there is a not finished rollback of a previous + * entry. + */ + JOURNAL_ENTRY_ERR_CASCADE = -3, /** * Anchor for the structs built on top of journal entry so as they * could introduce their own unique errors. Set to a big value in diff --git a/src/box/txn.h b/src/box/txn.h index 037865ac6..7638854a7 100644 --- a/src/box/txn.h +++ b/src/box/txn.h @@ -110,6 +110,7 @@ enum { */ TXN_SIGNATURE_UNKNOWN = JOURNAL_ENTRY_ERR_UNKNOWN, TXN_SIGNATURE_IO = JOURNAL_ENTRY_ERR_IO, + TXN_SIGNATURE_CASCADE = JOURNAL_ENTRY_ERR_CASCADE, /** * The default signature value for failed transactions. * Indicates either write failure or any other failure diff --git a/src/box/wal.c b/src/box/wal.c index f59cc9113..8543c4a08 100644 --- a/src/box/wal.c +++ b/src/box/wal.c @@ -1036,6 +1036,7 @@ wal_write_to_disk(struct cmsg *msg) { struct wal_writer *writer = &wal_writer_singleton; struct wal_msg *wal_msg = (struct wal_msg *) msg; + int err_code = JOURNAL_ENTRY_ERR_UNKNOWN; struct stailq_entry *last_committed = NULL; struct journal_entry *entry; struct error *error; @@ -1059,16 +1060,19 @@ wal_write_to_disk(struct cmsg *msg) if (writer->is_in_rollback) { /* We're rolling back a failed write. */ + err_code = JOURNAL_ENTRY_ERR_CASCADE; goto done; } /* Xlog is only rotated between queue processing */ if (wal_opt_rotate(writer) != 0) { + err_code = JOURNAL_ENTRY_ERR_IO; goto done; } /* Ensure there's enough disk space before writing anything. */ if (wal_fallocate(writer, wal_msg->approx_len) != 0) { + err_code = JOURNAL_ENTRY_ERR_IO; goto done; } @@ -1104,8 +1108,10 @@ wal_write_to_disk(struct cmsg *msg) entry->res = vclock_sum(&vclock_diff) + vclock_sum(&writer->vclock); rc = xlog_write_entry(l, entry); - if (rc < 0) + if (rc < 0) { + err_code = JOURNAL_ENTRY_ERR_IO; goto done; + } if (rc > 0) { writer->checkpoint_wal_size += rc; last_committed = &entry->fifo; @@ -1114,8 +1120,10 @@ wal_write_to_disk(struct cmsg *msg) /* rc == 0: the write is buffered in xlog_tx */ } rc = xlog_flush(l); - if (rc < 0) + if (rc < 0) { + err_code= JOURNAL_ENTRY_ERR_IO; goto done; + } writer->checkpoint_wal_size += rc; last_committed = stailq_last(&wal_msg->commit); @@ -1167,12 +1175,15 @@ done: stailq_cut_tail(&wal_msg->commit, last_committed, &rollback); if (!stailq_empty(&rollback)) { + assert(err_code != JOURNAL_ENTRY_ERR_UNKNOWN); /* Update status of the successfully committed requests. */ stailq_foreach_entry(entry, &rollback, fifo) - entry->res = JOURNAL_ENTRY_ERR_IO; + entry->res = err_code; /* Rollback unprocessed requests */ stailq_concat(&wal_msg->rollback, &rollback); wal_begin_rollback(); + } else { + assert(err_code == JOURNAL_ENTRY_ERR_UNKNOWN); } fiber_gc(); wal_notify_watchers(writer, WAL_EVENT_WRITE); -- 2.24.3 (Apple Git-128)