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 838A96EC5F; Tue, 2 Mar 2021 01:05:29 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 838A96EC5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1614636329; bh=sS9pFUH73eoFh8X1fqZycSjzaaxXKn+YqiwiuhB4RTs=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=VWCXAyIq+J/w5jI5bTO8tHjBN5iDPNlbuXtCkK4nu4wkm1O7UY/Ep6xJyym3gF0hl +Ty/x+1W6mZmr/oi2ux6E9jN/OcVkl4zSwn+Bl2sYRII7D66vz+PsJOtK1urq4Gw5a OOr3t2EHJ0upc16Ir5MhuHzqmUI16iHyvBXFC5qU= 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 129496EC5F for ; Tue, 2 Mar 2021 01:05:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 129496EC5F Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1lGqfP-0005CD-0k; Tue, 02 Mar 2021 01:05:27 +0300 To: Serge Petrenko , gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org References: <20210224193549.70017-1-sergepetrenko@tarantool.org> <469ef629-699c-0180-facb-f166d6d3c073@tarantool.org> <17046c4d-b239-f3d8-f150-941026096b1e@tarantool.org> Message-ID: Date: Mon, 1 Mar 2021 23:05:26 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <17046c4d-b239-f3d8-f150-941026096b1e@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD92A98208ECBDD29F5A6709E93A77B8502A831FF4624BDF5D2182A05F5380850402B947416E60A22409B8CFA855C2BAEB263DA4CC63CFB91F2A80569992EE26CC6 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7370F4F695FFFC24BEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637D24CDE3D695BBBC6EA1F7E6F0F101C674E70A05D1297E1BBC6CDE5D1141D2B1C4A7E474E9A93EE2353E26FE064B91784B99B5EE6C4E5C4D69FA2833FD35BB23D9E625A9149C048EE33AC447995A7AD1828451B159A507268D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8B5FC25ED3FCEC3375A471835C12D1D977C4224003CC836476EC64975D915A344093EC92FD9297F6718AA50765F7900637B8F435DEDE9E76EBA7F4EDE966BC389F395957E7521B51C24C7702A67D5C33162DBA43225CD8A89F0A35B161A8BF67C142539A7722CA490CB5C8C57E37DE458B4C7702A67D5C3316FA3894348FB808DB985633C00BAEBE4F574AF45C6390F7469DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A556F01DBDE192F69B37AB4DDACF5DB4A7EEEC1940CFDA71F6D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75448CF9D3A7B2C848410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34C6EC1BD9807109D2CACB89BF99C400470D16FF8608C63C57702E5041B152F65F28AD5408CD6248B91D7E09C32AA3244C9BF74045FC800495AC39508F1956BDF8259227199D06760AFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojnpKwxR6GFbuo7dp6Qw0/gw== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822ED7E4F702EB17C681B68FD51A0134DAF3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v3] wal: introduce limits on simultaneous writes 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" Hi! Thanks for the fixes! >>> @@ -159,6 +276,13 @@ journal_write(struct journal_entry *entry) >>>   static inline int >>>   journal_write_async(struct journal_entry *entry) >>>   { >>> +    /* >>> +     * It's the job of the caller to check whether the queue is full prior >>> +     * to submitting the request. >>> +     */ >>> +    assert(!journal_queue_is_full() || journal_queue.is_ready); >>> +    journal_queue_on_append(entry); >> 8. Probably must assert that waiters list is empty. Otherwise you >> could go out of order. > > It's not empty by the time the first entry gets to 'journal_write_async'. > Everyone else is waken up, but not yet removed from the queue. > > Looks like we cannot determine whether a write is called after waiting in queue > or not. It bothers me a lot, the rest looks good. We don't have any protection against a reorder, even not an assertion. How about this? (I didn't test): ==================== --- a/src/box/journal.c +++ b/src/box/journal.c @@ -69,8 +69,11 @@ void journal_queue_wakeup(void) { struct rlist *list = &journal_queue.waiters; - if (!rlist_empty(list) && !journal_queue_is_full()) + if (!rlist_empty(list) && !journal_queue_is_full()) { fiber_wakeup(rlist_first_entry(list, struct fiber, state)); + --journal_queue.waiter_count; + assert(journal_queue.waiter_count >= 0); + } } void @@ -84,7 +87,6 @@ journal_queue_wait(void) * Will be waken up by either queue emptying or a synchronous write. */ fiber_yield(); - --journal_queue.waiter_count; journal_queue_wakeup(); } @@ -96,5 +98,6 @@ journal_queue_flush(void) struct rlist *list = &journal_queue.waiters; while (!rlist_empty(list)) fiber_wakeup(rlist_first_entry(list, struct fiber, state)); + journal_queue.waiter_count = 0; journal_queue_wait(); } diff --git a/src/box/journal.h b/src/box/journal.h index 5f0e0accd..ea56043e2 100644 --- a/src/box/journal.h +++ b/src/box/journal.h @@ -260,6 +260,7 @@ journal_write_async(struct journal_entry *entry) * to submitting the request. */ journal_queue_on_append(entry); + assert(journal_queue.waiter_count == 0); return current_journal->write_async(current_journal, entry); }