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 DE6646EC55; Wed, 5 May 2021 23:47:26 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DE6646EC55 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1620247647; bh=GNloVbKzHXQrzuqs+pg5unyVvCyktDzXLwNP1drncnw=; 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=K6ibPzmaI8VV3CMldxT/6G47Ffj4RYF5Te+yxUa44VD/9YRpQSHECewr1HAYId6Qg GoASdJp4eZef+PTocpA0IvS6LGVuS2G+AKlLHGuxkCHRxYQMkLPiuoznApOt2Qz9Pz /dkyo7HbLcZDTNrgZqksou4W2UtNWr4akEXwOack= Received: from smtp48.i.mail.ru (smtp48.i.mail.ru [94.100.177.108]) (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 BF14C6EC55 for ; Wed, 5 May 2021 23:47:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BF14C6EC55 Received: by smtp48.i.mail.ru with esmtpa (envelope-from ) id 1leOQW-0008OK-84; Wed, 05 May 2021 23:47:24 +0300 To: Cyrill Gorcunov References: <20210430153940.121271-1-gorcunov@gmail.com> <20210430153940.121271-3-gorcunov@gmail.com> <6984ca72-28ec-d86f-5653-c3beff626158@tarantool.org> Message-ID: <5c0161b3-0f00-901d-1c94-f40915fe6f6b@tarantool.org> Date: Wed, 5 May 2021 22:47:23 +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: 7bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD95978C26455E69BE022900C3053DBED76BEB47C8A8E1FDA50182A05F5380850404278C41C4FB2A8BE16B355C2F88D9C787CC044346090662443F6371D8B159961 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7F6EE1C40B2E8BE15EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063729381D024F10DD158638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B235A99D057E1E9C3C84AC31769B075F73618001F51B5FD3F9D2E47CDBA5A96583C09775C1D3CA48CF776A0366D588B3C3117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE74F330F0740BBDD1F9FA2833FD35BB23DF004C90652538430302FCEF25BFAB3454AD6D5ED66289B5278DA827A17800CE70DF4791E4DA23945D32BA5DBAC0009BE395957E7521B51C20BC6067A898B09E4090A508E0FED6299176DF2183F8FC7C0C693CACC2C5C60F7CD04E86FAF290E2D7E9C4E3C761E06A71DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6A1DCCEB63E2F10FB089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2368A440D3B0F6089093C9A16E5BC824A2A04A2ABAA09D25379311020FFC8D4ADA59E58988AB0FD80298349CAD9B77599 X-C1DE0DAB: 0D63561A33F958A52A849EAD2FB72F131E2F8160513E3D05B4BC94F763535851D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3454548929AF40B4285D51533CB25E143AD538E7E50F811DA0F728C77341A2D1801930E55491DD98721D7E09C32AA3244CCC2714B3FB4D95499179DAD4CBE7D45C7101BF96129E401183B48618A63566E0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojyPGyeJvdNBnBzERQR2WVFg== X-Mailru-Sender: 504CC1E875BF3E7D9BC0E5172ADA31103F0A281AE27328431AB7DF794403629AAC7AB365EE4EB87F07784C02288277CA03E0582D3806FB6A5317862B1921BA260ED6CFD6382C13A6112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [RFC v3 2/3] applier: send first row's WAL time in the applier_writer_f 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: Mons Anderson , tml Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi! Thanks for the response! >>> + uint32_t instance_id; >>> + double first_row_tm; >>> +}; >>> + >>> +static void >>> +awstat_update(struct awstat *awstat) >>> +{ >>> + /* Ignore if not needed */ >>> + if (awstat->instance_id == 0) >>> + return; >> >> 2. Why did you even allocate this stat if it is not needed? >> Maybe it would be better to have it NULL then and check >> for NULL? AFAIU these are the initial and final join cases. > > They are allocated on the stack together with synchro_entry, > so there is no penalty. They are allocated on the region for plain transactions, which are way more important to optimize. >> Did you try the way I proposed about waiting for all applier's >> WAL writes to end in applier_stop()? Does it look worse? After >> the fiber stop and wal_sync() it would be safe to assume there >> are no WAL writes in fly from this applier. But I don't know if >> it would look better. > > I thought about it alot. And you know, I don't really like what we > are to implement > > - currently applier_stop() doesn't wait the journal to finish its > write. The main applier reader is spinning in !fiber_is_cancelled() > cycle in a polling way while applier tries to read new data from the > remote relay peer. If peer doesn't reply for some reason then we throw > an exception which is catched by a caller code, and the caller tries > to iterate new cycle testing if fiber is cancelled. I do not follow here. You needed to wait only for the pending journal writes. It has nothing to do with reading new data from anywhere, does it? > - in applier_stop() we will have to implement some kind of reference > counting, which would be modified on journal completion and i think > this makes code even more complex, since we have to add some additional > logic when applier is allowed to cancel. We don't really. You only need to call wal_sync() after which you can be sure all the WAL writes started before this call now are finished. At least AFAR it works. But these refs might be needed for assertions, so yes, maybe not a good idea. >>> + return; >>> + >>> + r->applier->first_row_wal_time = awstat->first_row_tm; >> >> 4. In case there was a batch of transactions written to WAL, >> the latest one will override the timestamp of the previous ones and >> this would make the lag incorrect, because you missed the older >> transactions. Exactly like when you tried to take a timestamp of >> the last row instead of the first row, but in a bigger scope. >> Unless I missed something. > > I'm not sure I follow you here. Say we have a batch of transactions. > The update happens on every journal_entry completion, if several > entries are flushed then completion is called in ordered way (one > followed by another). Exactly. The latest update will override the previous timestamps. > The update happens in same tx thread where > appliers are running which means acks sending procedure is ordered > relatively to updates call. Thus we may have situation where we > complete first entry then we either send it in ack message either > update to a new value and only then send ack. In one event loop iteration many transactions might be submitted to WAL by the applier. And they will end also in one event loop iteration later. There won't even be any yields between their completions. Yes, first of them will wakeup the ack-sender fiber, but the next ones will override the first timestamp. After a yield the ACK will contain the newest timestamp ignoring the timestamps of the older transactions. > As far as I understand > there might be a gap in fibers scheduling before several journal entries > get completed. Thus the lag calculated on relay side will be bigger for > some moment but on next ack will shrink to latest entry for writtent > journal entry. On the contrary, it will be smaller on the other side than it is. Because you send the ACK with the latest timestamp instead of the oldest one. Smaller would be misleading about the real latency. Unless I don't understand something. > Because relay uses current time minus time value > obtained from applier's ack. Hopefully I didn't miss something either. > >> Probably you need to assign a new timestamp only when the old >> one is not 0, and reset it to 0 on each sent ACK. Don't know. > > Gimme some time to investigate this vague moment.