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 703306F87A; Wed, 28 Apr 2021 23:50:46 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 703306F87A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1619643046; bh=0YipEf2JtreHgUB3jG5za6Eq2l59MoEf3E3mXH0YVms=; 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=BmWJQXV4sWygRBpv1llfqAQjx99M6QLpbsqLexqTa7/eh51OTAE0DMJTV1HbIQJNc WneG+f8Me3YGLrO+8P2SAmKw+kMDL1uaadgGM1T0d1t5FmQ5BhFa2NvoIn9KavD9dk asbGmFAHNP7Z7N5OkpMT150usILYlSvTrzCtxhAk= Received: from smtp35.i.mail.ru (smtp35.i.mail.ru [94.100.177.95]) (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 430466F87A for ; Wed, 28 Apr 2021 23:50:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 430466F87A Received: by smtp35.i.mail.ru with esmtpa (envelope-from ) id 1lbr8u-0007Xl-Fg; Wed, 28 Apr 2021 23:50:44 +0300 To: Serge Petrenko , gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org References: <20210426165954.46474-1-sergepetrenko@tarantool.org> Message-ID: <738d3030-80cf-8079-1b03-55a7d665dbbf@tarantool.org> Date: Wed, 28 Apr 2021 22:50:43 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9ECFD8CE5F0594010172C8F5787C1B7A21B115C62DFC52C90182A05F538085040C2607BC440AC5CA9E82D24DCF21DD7E0518AD74AD8093AFB4C7834F4B22222CD X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE71D16D29A965DB9EEEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006378D08D652E28591A78638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B2CD854DB8931EE7E52E544A2F6BB25B3C4A8204C501E24153D2E47CDBA5A96583C09775C1D3CA48CF32941D3B652364A4117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE73D04F0695778128A9FA2833FD35BB23DF004C90652538430302FCEF25BFAB3454AD6D5ED66289B5278DA827A17800CE78BD0D9EB147C554FD32BA5DBAC0009BE395957E7521B51C20BC6067A898B09E4090A508E0FED6299176DF2183F8FC7C019CFE3F165F3D3B7CD04E86FAF290E2D7E9C4E3C761E06A71DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6AC294AFEFA671E80089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A24209795067102C07E8F7B195E1C978316BA442456FC9271945A0E006394C2ED0 X-C1DE0DAB: 0D63561A33F958A5EE28563C09B83942395A5B073F313971724997F561596134D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D346B71C4B0698719D717B233C0584931AAB0FD9F145251F2B8242A6800DB67FD23A5CC209717B11D841D7E09C32AA3244C432EC51D51ECC4DAC0F4950206C8EC717C0C08F7987826B9FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojoCaqxM2e5sqTPqYc+XHOTQ== X-Mailru-Sender: 504CC1E875BF3E7D9BC0E5172ADA3110933B43A79A6838AB318DD565DB9CA8F6AF98F4AA61F60FF307784C02288277CA03E0582D3806FB6A5317862B1921BA260ED6CFD6382C13A6112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH] recovery: make it yield when positioning in a WAL 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" >>> We had various places in box.cc and relay.cc which counted processed >>> rows and yielded every now and then. These yields didn't cover cases, >>> when recovery has to position inside a long WAL file: >>> >>> For example, when tarantool exits without leaving an empty WAL file >>> which'll be used to recover instance vclock on restart. In this case >>> the instance freezes while processing the last availabe WAL in order >>> to recover the vclock. >>> >>> Another issue is with replication. If a replica connects and needs data >>> from the end of a really long WAL, recovery will read up to the needed >>> position without yields, making relay disconnect by timeout. >>> >>> In order to fix the issue, make recovery decide when a yield should >>> happen. Introduce a new callback: schedule_yield, which is called by >>> recovery once it processes (no matter how, either simply skips or calls >>> xstream_write) enough rows (WAL_ROWS_PER_YIELD). >>> >>> schedule_yield either yields right away, in case of relay, or saves the >>> yield for later, in case of local recovery, because it might be in the >>> middle of a transaction. >> 1. Did you consider an option to yield explicitly in recovery code when >> it skips rows? If they are being skipped, it does not matter what are >> their transaction borders. > > I did consider that. It is possible to do so, but then we'll have yet another > place (in addition to relay and wal_stream) which counts rows and yields > every now and then. > > I thought it would be better to unify all these places. Actually, this could be > done this way from the very beginning. > I think it's not recovery's business whether to yield or not once > some rows are processed. > > Anyway, I can make it this way, if you insist. The current solution is also fine. >>> + >>> +/** >>> + * Plan a yield in recovery stream. Wal stream will execute it as soon as it's >>> + * ready. >>> + */ >>> +static void >>> +wal_stream_schedule_yield(void) >>> +{ >>> +    wal_stream.has_yield = true; >>> +    wal_stream_try_yield(&wal_stream); >>> +} >>> diff --git a/src/box/recovery.cc b/src/box/recovery.cc >>> index cd33e7635..5351d8524 100644 >>> --- a/src/box/recovery.cc >>> +++ b/src/box/recovery.cc >>> @@ -241,10 +248,16 @@ static void >>>   recover_xlog(struct recovery *r, struct xstream *stream, >>>            const struct vclock *stop_vclock) >>>   { >>> +    /* Imitate old behaviour. Rows are counted separately for each xlog. */ >>> +    r->row_count = 0; >> 3. But why do you need to imitate it? Does it mean if the files are >> too small to yield even once in each, but in total their number is >> huge, there won't be yields? > > Yes, that's true. Does not this look wrong to you? The xlog files might not contain enough rows if wal_max_size is small enough, and then the same issue still exists - no yields. >> Also does it mean "1M rows processed" was not ever printed in that >> case? > > Yes, when WALs are not big enough. > Recovery starts over with '0.1M rows processed' on every new WAL file. Does not this look wrong to you too? That at least the number of rows should not drop to 0 on each next xlog file.