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 E5FC76EC70; Sat, 12 Jun 2021 01:00:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E5FC76EC70 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1623448853; bh=NpGQSE4+4N0/oJJhCAp1Y+YRVmUE7c4xiPF/c8SD8Gs=; 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=hpkHxpLfHvg28QFal18quFpkcKj+3B3Dp75YXUE0lUNfvFVTkLt/ml1kjrEvp7btY QuxEnkDHM2xSgcYGio+NBxn3jraj2M9ulSajbYhIeL3olJKoAr27Jt9U3PZmDHpea4 KLR2NuBCGttqxt9NZdcAsxjR+9G8OnZCEpksdIHc= 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 09A1C6F3C3 for ; Sat, 12 Jun 2021 00:56:30 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 09A1C6F3C3 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1lrp8f-0008JK-4S; Sat, 12 Jun 2021 00:56:29 +0300 To: tarantool-patches@dev.tarantool.org, gorcunov@gmail.com, sergepetrenko@tarantool.org Date: Fri, 11 Jun 2021 23:56:12 +0200 Message-Id: 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: 4F1203BC0FB41BD9D5B0DA836B685C544BBC2A69B1B4100B389BF69B7A224D7C182A05F53808504044C930E57681CBFE4BEFDA724293828621D1D990C966326F453FB98444782EC4 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE78EA80DE462DCD770EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637575FD8E213AF258FEA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BD6CF32B5F8F9D40452B2D22B93D6649470D8F3D12DD4435DCC7F00164DA146DAFE8445B8C89999728AA50765F7900637F6B57BC7E64490618DEB871D839B7333395957E7521B51C2DFABB839C843B9C08941B15DA834481F8AA50765F7900637F3E38EE449E3E2AE389733CBF5DBD5E9B5C8C57E37DE458B9E9CE733340B9D5F3BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B093A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E735F43AACC0BCEB2632C4224003CC83647689D4C264860C145E X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C978317387390EF8EF1240F58DDC17270A414D X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8183A4AFAF3EA6BDC44C234C8B12C006B7A1906CDB4DF5A72909B7983328A205C4134E91B96C0A298C1B1881A6453793CE9C32612AADDFBE061C61BE10805914D3804EBA3D8E7E5B87ABF8C51168CD8EBDB791E6C230873D55CDC48ACC2A39D04F89CDFB48F4795C241BDAD6C7F3747799A X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34AF12ADB97C97CD89BB0EA21CD4073F9705259EF49C9BC6771B0347A8D0B06B224580443F5E6DFDB71D7E09C32AA3244CDBE78926D88166DF4CD23637FD6B5B3AFE8DA44ABE2443F7FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojQR1NM653rVGKC5SEP9Xlgw== X-Mailru-Sender: 689FA8AB762F73936BC43F508A06382283D0DEBC66DC8BDFE110B9EEC0ED0BD73841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH 04/13] wal: refactor wal_write_to_disk() 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 didn't have a single fail path. That led to some amount of code duplication, and it complicated future patches where the journal entries are going to get a proper error reason instead of default -1 without any details. The patch is a preparation for #6027 where it is wanted to have more detailed errors on journal entry/transaction fail instead of ER_WAL_IO for everything. Sometimes it can override a real error like a cascade rollback, or a transaction conflict. Part of #6027 --- src/box/wal.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/box/wal.c b/src/box/wal.c index 25edbace6..40382e791 100644 --- a/src/box/wal.c +++ b/src/box/wal.c @@ -863,10 +863,8 @@ wal_opt_rotate(struct wal_writer *writer) return 0; if (xdir_create_xlog(&writer->wal_dir, &writer->current_wal, - &writer->vclock) != 0) { - diag_log(); + &writer->vclock) != 0) return -1; - } /* * Keep track of the new WAL vclock. Required for garbage * collection, see wal_collect_garbage(). @@ -1038,7 +1036,10 @@ wal_write_to_disk(struct cmsg *msg) { struct wal_writer *writer = &wal_writer_singleton; struct wal_msg *wal_msg = (struct wal_msg *) msg; + struct stailq_entry *last_committed = NULL; + struct journal_entry *entry; struct error *error; + assert(!stailq_empty(&wal_msg->commit)); /* * Track all vclock changes made by this batch into @@ -1058,23 +1059,17 @@ wal_write_to_disk(struct cmsg *msg) if (writer->is_in_rollback) { /* We're rolling back a failed write. */ - stailq_concat(&wal_msg->rollback, &wal_msg->commit); - vclock_copy(&wal_msg->vclock, &writer->vclock); - return; + goto done; } /* Xlog is only rotated between queue processing */ if (wal_opt_rotate(writer) != 0) { - stailq_concat(&wal_msg->rollback, &wal_msg->commit); - vclock_copy(&wal_msg->vclock, &writer->vclock); - return wal_begin_rollback(); + goto done; } /* Ensure there's enough disk space before writing anything. */ if (wal_fallocate(writer, wal_msg->approx_len) != 0) { - stailq_concat(&wal_msg->rollback, &wal_msg->commit); - vclock_copy(&wal_msg->vclock, &writer->vclock); - return wal_begin_rollback(); + goto done; } /* @@ -1104,8 +1099,6 @@ wal_write_to_disk(struct cmsg *msg) * Iterate over requests (transactions) */ int rc; - struct journal_entry *entry; - struct stailq_entry *last_committed = NULL; stailq_foreach_entry(entry, &wal_msg->commit, fifo) { wal_assign_lsn(&vclock_diff, &writer->vclock, entry); entry->res = vclock_sum(&vclock_diff) + -- 2.24.3 (Apple Git-128)