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 C63CE6EC40; Mon, 7 Jun 2021 22:21:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C63CE6EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1623093685; bh=TVvQ12iZwAt0PmXBib9U0Td1ZSar3rcKPuZklTz8nDs=; 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=RBwET37S+ReVmLMPfyg5RsZqA/8k1vGACP29GEPcH2jV3ctZODiEb83D80vKsjXhU 1YflQDs0vvBRBrhirqSl00Fx5pY6qXF55AmVuMeTJgq4jPXFmG3n6aHzSTtobjeZst j9gGDi44fx+/scL2YzjrBJvUDJILfr9SVkRr1KZY= Received: from smtp43.i.mail.ru (smtp43.i.mail.ru [94.100.177.103]) (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 C130F6EC40 for ; Mon, 7 Jun 2021 22:20:59 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C130F6EC40 Received: by smtp43.i.mail.ru with esmtpa (envelope-from ) id 1lqKnz-0002pA-9H; Mon, 07 Jun 2021 22:20:59 +0300 To: Cyrill Gorcunov , tml References: <20210607155519.109626-1-gorcunov@gmail.com> <20210607155519.109626-2-gorcunov@gmail.com> Message-ID: <6273f141-4455-c017-8542-65c50360cb95@tarantool.org> Date: Mon, 7 Jun 2021 21:20:58 +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: <20210607155519.109626-2-gorcunov@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9D5B0DA836B685C546075B3437CB362FF47FF2EE3FBA69D6F182A05F5380850408CC63768DEF7BA16601A68A9AB36224BAB9ED985A3822261F56F2F5083C57E2B X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7235646FAB97B4BEDEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637EDC9855826FBDF5A8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8576C2743EBCA4B171FF3A77659C2B93E117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCEA77C8EAE1CE44B0A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735209647ADFADE5905B1CB629EEF1311BF91D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE140C956E756FBB7AC67AC315686ED4D3D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE35FF72824B19451C6C0837EA9F3D19764C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F79006373BC478629CBEC79DEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A24209795067102C07E8F7B195E1C97831826B4634A215394967D7C3C64BB55547 X-C1DE0DAB: 0D63561A33F958A50746547FE57F2D81529E0A2EDC7ECA34F2CC475D86474A91D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75FBC5FED0552DA851410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3473688ED311681BF019D02A7207B68505D0C2363EF7C60C3BE9728CB8C45FF70C259179CA32CD114F1D7E09C32AA3244C3784EB3D5AEF5F80E9C053EBF3AD854A3A92A9747B6CC886729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj/099YK7Sav08arceV8RrBA== X-Mailru-Sender: 504CC1E875BF3E7D9BC0E5172ADA3110BAF80A8638872315CC77F9C3E891A14EF5B6E8D71E0747C407784C02288277CA03E0582D3806FB6A5317862B1921BA260ED6CFD6382C13A6112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v8 1/2] applier: send transaction's first row 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 Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thanks for the patch! > diff --git a/src/box/applier.cc b/src/box/applier.cc > index 33181fdbf..38695a54f 100644 > --- a/src/box/applier.cc > +++ b/src/box/applier.cc> @@ -751,11 +764,35 @@ applier_txn_rollback_cb(struct trigger *trigger, void *event) > return 0; > } > > +struct replica_cb_data { > + /** Replica ID the data belongs to. */ > + uint32_t replica_id; > + /** > + * Timestamp of a transaction to be accounted > + * for relay lag. Usually it is a first row in > + * a transaction. > + */ > + double txn_start_tm; > +}; > + > +/** Update replica associated data once write is complete. */ > +static void > +replica_txn_wal_write_cb(struct replica_cb_data *rcb) > +{ > + struct replica *r = replica_by_id(rcb->replica_id); > + if (likely(r != NULL)) > + r->applier_txn_start_tm = rcb->txn_start_tm; I spent some time trying to understand why did you delete the check that we should not override the timestamp until its ACK is sent. But then I realized that indeed the correct way is to send the latest timestamp of a tx batch, not the first one. Because the replica confirms receipt of the transactions up to the latest one. I am 90% sure it is correct. And you need to add a comment here why do you use the latest timestamp. Also that means you need to use the last row's timestamp, not the first row's one. By the same reason. I doubt they are different, but still it would be more correct. In apply_plain_tx() below you should use last stailq entry, not first entry. > @@ -931,10 +978,21 @@ apply_plain_tx(struct stailq *rows, bool skip_conflict, bool use_triggers) > goto fail; > } > > + struct replica_cb_data *rcb; > + rcb = region_alloc_object(&txn->region, typeof(*rcb), &size); > + if (rcb == NULL) { > + diag_set(OutOfMemory, size, "region_alloc_object", "rcb"); > + goto fail; > + } > + > trigger_create(on_rollback, applier_txn_rollback_cb, NULL, NULL); > txn_on_rollback(txn, on_rollback); > > - trigger_create(on_wal_write, applier_txn_wal_write_cb, NULL, NULL); > + item = stailq_first_entry(rows, struct applier_tx_row, next); > + rcb->replica_id = replica_id; > + rcb->txn_start_tm = item->row.tm; > + > + trigger_create(on_wal_write, applier_txn_wal_write_cb, rcb, NULL); > txn_on_wal_write(txn, on_wal_write); > }