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 69DD76EC55; Sat, 12 Jun 2021 00:57:33 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 69DD76EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1623448653; bh=HtrlEI75O6ZCtlcib2cmKEEzXcluIpJrtDY+vDrrTHs=; 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=aXx2rGG4Kwhw8JGyTYwOFWu07QvflR7OtTfgouA9oI5L/6gOuU/7QB5Y/CVRQgj5t QP8J8O+0FVXoJ9htZssDX8zBeTW7Bpz4t9bh/lGF6BBNyeygQBDr4qQZDi+IIcZlSY G4TvEtKBxHNPBlKhwwtyb6fS6gZJeyAtrRXW5Cfo= 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 888206EC5C for ; Sat, 12 Jun 2021 00:56:21 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 888206EC5C Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1lrp8W-0008JK-N5; Sat, 12 Jun 2021 00:56:21 +0300 To: tarantool-patches@dev.tarantool.org, gorcunov@gmail.com, sergepetrenko@tarantool.org Date: Fri, 11 Jun 2021 23:56:06 +0200 Message-Id: <82c470d34b0e86bbb643c83da236ad07462876d2.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: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD9D5B0DA836B685C5407454A95E60932C8E3171F0D0805CD56182A05F538085040E53A92435D1480311EF0888A7136683D0D6DEE79880E3F1ED8313DA9850CFF3B X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE797F4D2EDC29AFAF7EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637E1D2769089B3DFB28638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D89EF0C58C63AD2E6BD3B2BD9148088DE8117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCECADA55FE5B58BB7A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352026055571C92BF10FF04B652EEC242312D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6B1CFA6D474D4A6A4089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8183A4AFAF3EA6BDC44C234C8B12C006B7A1906CDB4DF5A729022CAB6583E0E256BA76AF0A4D90A2CCDB1881A6453793CE9C32612AADDFBE061C61BE10805914D3804EBA3D8E7E5B87ABF8C51168CD8EBDB791E6C230873D55CDC48ACC2A39D04F89CDFB48F4795C241BDAD6C7F3747799A X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D346BEB6F73FB9D1E4A397A7AA4647B4D0198FEF323E68B0D7DCC01029C1689C91FD23AFC605014EEAB1D7E09C32AA3244CDA715A4786B58244FAB85B9CF316283F05AB220A9D022EBCFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojQR1NM653rVHttvT6GrrLAQ== X-Mailru-Sender: 689FA8AB762F73936BC43F508A0638229784A96F9700388FC3BBB777B42DA0803841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH 10/13] txn: install proper diag errors on txn fail 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" 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)