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 C84496EC55; Thu, 17 Jun 2021 02:32:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C84496EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1623886376; bh=wxbywFyxbocaJygTImbUN+Wz3T0pKhoYHRFRa+KiTWU=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=LyBTFkFJQoadQCQ4HEsl2eJqA6NOYAIeZZ56NDXDEOfhPIfb2XRnuBxZgZEqVOWrq FcGViNDNg3cQiH6lAV4p+rlVS33rJwxEFWv7QrYTWz1bW+1RzzDzsX+/bZC6cBKc4U qVNv/lVLCjvvQltGb306RcojjDMazDIrVu5EqDrE= 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 DDF3B6EC55 for ; Thu, 17 Jun 2021 02:32:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DDF3B6EC55 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1ltf1i-0002DP-08; Thu, 17 Jun 2021 02:32:54 +0300 To: Cyrill Gorcunov References: <9940ffc4-9d92-58b7-e95a-1128048e21da@tarantool.org> Message-ID: Date: Thu, 17 Jun 2021 01:32:52 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9D5B0DA836B685C54F4BC37E91F2690B85F43D7652182C513182A05F538085040636875AD20D04A531720B4F2D83C6A3C103A1D4ED3CAFB4F1361FD9697EE3CB6 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE74EC61905B8C6A847EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637C218CA8E848E3B7A8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8F783B1FEB3F1A2162941E8A943B7C4A9117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18E5D25F19253116ADD2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B613439FA09F3DCB32089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C978315036C1033D58601FFA0551508B2C535B X-C1DE0DAB: 0D63561A33F958A5069FB6385ECFDA0CE8364CE37412CFEF42725D01784EE888D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75448CF9D3A7B2C848410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D345C064E16D8ABF335EF540E1D4560D62A6612AF366243BC2FECA5902ABFA23EF67EF7D05618C238661D7E09C32AA3244CD5FF33321378BC1C05F18928DB5C11BC3C6EB905E3A8056BFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojzTTns/+yd+YUxH8trCZ8vg== X-Mailru-Sender: 689FA8AB762F73936BC43F508A06382285ABF51D50660E8D9B4004FCE21714EE3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [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 Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi! Thanks for the review! >>>> @@ -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 error *error; >>>> + assert(!stailq_empty(&wal_msg->commit)); >>> >>> Hi Vlad, you know I don't understand why we need this assert... >> >> Otherwise in case of, for instance, rotate fail, the rollback won't >> start. > > But the current whole code logic is assuming that if commit chain > is empty then there was no data to write or rollback, iow codeflow > is using list emptiness as a sign of data to procceed. If we really > want to prohibit calling wal_write_to_disk with no entries then > maybe better put panic here? > > The wal_msg->commit entry is accessed later in code anyway via bpu, > which means that if we add > > if (stailq_empty(&wal_msg->commit)) > panic("wal: attempt to update vclock without data"); > > this won't cause perf degradation since after a few lines you gonna be > testing @commit again where bpu entry is already filled and this will > allow us to catch problems on release builds as well. > > Don't get me wrong please I simply don't like assert() with a passion > because it hides problems which might happen on release builds. > > Anyway, just a proposal, if you still prefer calling assert here, ok > let it be. I added the panic: ==================== diff --git a/src/box/wal.c b/src/box/wal.c index 40382e791..cb8b2eac1 100644 --- a/src/box/wal.c +++ b/src/box/wal.c @@ -1039,7 +1039,8 @@ wal_write_to_disk(struct cmsg *msg) struct stailq_entry *last_committed = NULL; struct journal_entry *entry; struct error *error; - assert(!stailq_empty(&wal_msg->commit)); + if (stailq_empty(&wal_msg->commit)) + panic("Attempted to write an empty batch to WAL"); /* * Track all vclock changes made by this batch into