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 C32356EC56; Tue, 16 Mar 2021 23:48:12 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C32356EC56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1615927692; bh=3G1xb+hJPxKnXU062vlYDcj22HR52ZE7Ni6Jt/AGDd4=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=UfQA4YCdO5tGbXoTfk2oshvnWy0kfrW2LxKvsM/OT5rGU7iIj50x6rjwDL3psOFSu kulsXau817BoIJjNrcVlTkx7aNZQ8/Ot0TJxKtxnBKtixYkxpe9NBdEwx9bGxkh1UB Jg0RBW/ueEfNXv40jGGZfbzsmV6w1WBvPPGPeq0g= 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 66A5B6EC56 for ; Tue, 16 Mar 2021 23:48:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 66A5B6EC56 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1lMGbq-0004QR-Kp; Tue, 16 Mar 2021 23:48:11 +0300 To: Serge Petrenko , Konstantin Osipov , gorcunov@gmail.com, tarantool-patches@dev.tarantool.org References: <20210224193549.70017-1-sergepetrenko@tarantool.org> <26fde1bf-a972-fe03-fffe-818839718394@tarantool.org> <20210310081804.GA87351@starling> <54666e16-f577-c9f5-e917-f834b7e4b8d5@tarantool.org> <07f4831b-2300-2bb0-28a3-9d49f197e951@tarantool.org> Message-ID: <973078e7-04b7-f6fb-1c71-3972e278f0f6@tarantool.org> Date: Tue, 16 Mar 2021 21:48:08 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <07f4831b-2300-2bb0-28a3-9d49f197e951@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD96485A7A9FC1318933D9BB3A6B6EC3969033B83865BA14179182A05F538085040A31A8C2B22EA0FD7276C23041D7F2A30E478DA4743AA8188543343A6281AC5FB X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7CE4525FFB91B9BBCEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637C6EF84A9D301917D8638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95CF89CA98302ED496FFB424606B50676F7B802E1CFAC443CCAA471835C12D1D9774AD6D5ED66289B5278DA827A17800CE74A95F4E53E8DCE969FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3BEC81E4AEBD6D2BF117882F4460429728AD0CFFFB425014E868A13BD56FB6657A7F4EDE966BC389F9E8FC8737B5C22490A62CEF541B197C8089D37D7C0E48F6CCF19DD082D7633A0E7DDDDC251EA7DABAAAE862A0553A39223F8577A6DFFEA7CDA0371536F40842743847C11F186F3C5E7DDDDC251EA7DABCC89B49CDF41148F90DBEB212AEC08F22623479134186CDE6BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: 2623F767319EFA42AC98609FCEE262F9192335DD689A58EBAE0174B7F1092AFB772CA28438279D928AB576A0D22129AE X-C1DE0DAB: 0D63561A33F958A5201BE8E3BA7D2C0CEA8266DE34B29FFA877BA75589349494D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75F04B387B5D7535DE410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D349F4E6BC39AAD02BB6988743A8CB39A3B37E8A7FF3A83BCA7266B43D0F52CB928E6D85264EFF92F791D7E09C32AA3244C5B4358CF8F09265D0450EC19DF69E3608894E9C85370243E927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojwV/GgY7Z4vX/cnQotMncZw== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822A527B5D7663309CC917FF75EAD33BD2D3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B 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! See 3 comments below. > Here's when the option comes in handy: > Imagine such a situation: there are 2 servers, a master and a replica, > and the replica is down for some period of time. While the replica is > down, the master serves requests at a reasonable pace, possibly close to > its WAL throughput limit. Once the replica reconnects, it has to receive > all the data master has piled up. Now there's no limit in speed at which > master sends the data to replica, and there's no limit at which > replica's applier submits corresponding write requests to WAL. This > leads to a situation when replica's WAL is never in time to serve the > requests and the amount of pending requests is constantly growing. > There's no limit for memory WAL write requests take, and this clogging > of WAL write queue may even lead to replica using up all the available > memory. > > Now, when `wal_queue_max_size` is set, appliers will stop reading new > transactions once the limit is reached. This will let WAL process all the > requests that have piled up and free all the excess memory. > > [tosquash] remove wal_queue_max_len 1. You forgot something, the last line. Also, while we are here, it probably would be easier for the doc team if the old behaviour was described using a past tense, while the new one using the present tense. Currently you use 'now' word both for the old and for the new behaviour. For instance, you say Now there's no limit in speed at which master sends the data to replica, and there's no limit at which replica's applier submits corresponding write requests to WAL But >now< there is a limit. Even if 'wal_queue_max_size' is not set, it works with the default value. > diff --git a/changelogs/unreleased/wal-queue-limit.md b/changelogs/unreleased/wal-queue-limit.md > new file mode 100644 > index 000000000..393932456 > --- /dev/null > +++ b/changelogs/unreleased/wal-queue-limit.md > @@ -0,0 +1,9 @@ > +## feature/core > + > +* Introduce the concept of WAL queue and 2 new configuration options: > + `wal_queue_max_len`, measured in transactions, with 100k default and > + `wal_queue_max_size`, measured in bytes, with 100 Mb default. 2. There is 1 option now, not 2. > + The options help limit the pace at which replica submits new transactions > + to WAL: the limits are checked every time a transaction from master is > + submitted to replica's WAL, and the space taken by a transaction is > + considered empty once it's successfully written (gh-5536).> diff --git a/src/box/journal.h b/src/box/journal.h > index 5d8d5a726..437257728 100644 > --- a/src/box/journal.h > +++ b/src/box/journal.h > @@ -124,6 +142,62 @@ struct journal { > + > +/** Set maximal journal queue size in bytes. */ > +static inline void > +journal_queue_set_max_size(int64_t size) > +{ > + journal_queue.max_size = size; > + journal_queue_wakeup(); > +} > + > +/** Increase queue size on a new write request. */ > +static inline void > +journal_queue_on_append(struct journal_entry *entry) 3. Since you will amend the patch anyway, you could also make the entry 'const', the same in journal_queue_on_complete(). > +{ > + journal_queue.size += entry->approx_len; > +} > + > +/** Decrease queue size once write request is complete. */ > +static inline void > +journal_queue_on_complete(struct journal_entry *entry) > +{ > + journal_queue.size -= entry->approx_len; > + assert(journal_queue.size >= 0); > +}