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 B81236E200; Fri, 18 Jun 2021 00:01:42 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B81236E200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1623963702; bh=Itg3pz/SoCejkydn3e9b645gwiAlI8eIQ31oD6vqSBM=; 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=OrIkXBgjlC4L8l0NWXyKGgsZsOzGJwaqHUrTNTkAN1/2XCH/VsoE1d2mIERDGrUAN hgV70/7aLxjQEno5vpj05tXlECY742ELEaT1sLbRUzEwAYixhjydPH+ZGuTuOfCkLV wmroLuKDYIsreGlwhCGT+KRO1zdWNjoB4KLoov2s= Received: from smtp58.i.mail.ru (smtp58.i.mail.ru [217.69.128.38]) (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 83B7A6E205 for ; Fri, 18 Jun 2021 00:00:15 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 83B7A6E205 Received: by smtp58.i.mail.ru with esmtpa (envelope-from ) id 1ltz7X-00059U-6Q; Fri, 18 Jun 2021 00:00:15 +0300 To: Vladislav Shpilevoy , gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org References: <2e1ee8330e3ce53517bcb489280bfa5191bb66fb.1623331925.git.sergepetrenko@tarantool.org> <3fa9f126-3205-ef6e-c25c-d58a26677adf@tarantool.org> Message-ID: Date: Fri, 18 Jun 2021 00:00:14 +0300 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: <3fa9f126-3205-ef6e-c25c-d58a26677adf@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD91C2C07775F13263A612E9F961DCF5576EBB1C736C2A4021700894C459B0CD1B95F74713781D5AA030E1FC4CD8B603435AE11324F96DF83CBF1CEB82050DA3836 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE77F4CDA15A4A01EA0EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006372CFCDE0CF3C283B78638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D82484C5C198005F8D65A8E42DF05693F6117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC8C7ADC89C2F0B2A5A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD186FD1C55BDD38FC3FD2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE4B6963042765DA4BE2071C6999E77799D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE38ED1AC82D843A2BB302FCEF25BFAB345C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637BC468E7E89D8C5D6EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2368A440D3B0F6089093C9A16E5BC824A2A04A2ABAA09D25379311020FFC8D4AD7067FEF890167A54DCD3EE26F09DA1A1 X-C1DE0DAB: 0D63561A33F958A5751F0FAF2245BB7B84C3C825E14668965C6D6904EA402F24D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75448CF9D3A7B2C848410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34D71B56C992F8AF193A1612A7749195562C376507D600FDC5A31362F8E70D0404248B36246A2420B91D7E09C32AA3244C4B8FF582295FAC3693CB56BF619DA0DA3FD9C8CA1B0515E0FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojo2TEchKDd+cAAtp7An+qbw== X-Mailru-Sender: 583F1D7ACE8F49BD9DF7A8DAE6E2B08A7335C388A1FBB6A3A286D04B1F3DF58E84355E15920591B3424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH 4/7] txn_limbo: persist the latest effective promote in snapshot 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: Serge Petrenko via Tarantool-patches Reply-To: Serge Petrenko Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 15.06.2021 23:59, Vladislav Shpilevoy пишет: > Danke schön für der Patch! > > See 3 comments below. > >> diff --git a/src/box/memtx_engine.c b/src/box/memtx_engine.c >> index 6c4982b9f..3713d39d0 100644 >> --- a/src/box/memtx_engine.c >> +++ b/src/box/memtx_engine.c >> @@ -225,6 +226,22 @@ memtx_engine_recover_raft(const struct xrow_header *row) >> return 0; >> } >> >> +static int >> +memtx_engine_recover_promote(const struct xrow_header *row) > 1. Maybe call it recover_synchro instead of promote? Even in the > body PROMOTE is not mentioned anyhow except for the assertion. > What if we ever add more members to the synchro state? Ok. >> +{ >> + assert(row->type == IPROTO_PROMOTE); >> + struct synchro_request req; >> + if (xrow_decode_synchro(row, &req) != 0) >> + return -1; >> + /* >> + * Origin id cannot be deduced from row.replica_id in a checkpoint, >> + * because all it's rows have a zero replica_id. >> + */ >> + req.origin_id = req.replica_id; >> + txn_limbo_process(&txn_limbo, &req); >> + return 0; >> +} >> @@ -655,6 +676,17 @@ finish: >> return rc; >> } >> >> +static int >> +checkpoint_write_promote(struct xlog *l, const struct synchro_request *req) >> +{ >> + struct xrow_header row; >> + char body[XROW_SYNCHRO_BODY_LEN_MAX]; >> + xrow_encode_synchro(&row, body, req); >> + if (checkpoint_write_row(l, &row) != 0) >> + return -1; >> + return 0; > 2. Could also make 'return checkpoint_write_row(...);' > without branching + that might activate the tail call > optimization. Sure, thanks for noticing! >> diff --git a/src/box/txn_limbo.h b/src/box/txn_limbo.h >> index e409ac657..84a19bb40 100644 >> --- a/src/box/txn_limbo.h >> +++ b/src/box/txn_limbo.h >> @@ -311,6 +311,12 @@ txn_limbo_process(struct txn_limbo *limbo, const struct synchro_request *req); >> int >> txn_limbo_wait_confirm(struct txn_limbo *limbo); >> >> +/** >> + * Persist limbo state to a given synchro request. >> + */ >> +void >> +txn_limbo_checkpoint(struct txn_limbo *limbo, struct synchro_request *req); > 3. Lets make the limbo a const pointer. It does not change, does it? Ok. Please, find the incremental diff below. ================================== diff --git a/src/box/memtx_engine.c b/src/box/memtx_engine.c index a2ba17855..a2cfb2615 100644 --- a/src/box/memtx_engine.c +++ b/src/box/memtx_engine.c @@ -227,7 +227,7 @@ memtx_engine_recover_raft(const struct xrow_header *row)  }  static int -memtx_engine_recover_promote(const struct xrow_header *row) +memtx_engine_recover_synchro(const struct xrow_header *row)  {      assert(row->type == IPROTO_PROMOTE);      struct synchro_request req; @@ -235,7 +235,7 @@ memtx_engine_recover_promote(const struct xrow_header *row)          return -1;      /*       * Origin id cannot be deduced from row.replica_id in a checkpoint, -     * because all it's rows have a zero replica_id. +     * because all its rows have a zero replica_id.       */      req.origin_id = req.replica_id;      txn_limbo_process(&txn_limbo, &req); @@ -251,7 +251,7 @@ memtx_engine_recover_snapshot_row(struct memtx_engine *memtx,          if (row->type == IPROTO_RAFT)              return memtx_engine_recover_raft(row);          if (row->type == IPROTO_PROMOTE) -            return memtx_engine_recover_promote(row); +            return memtx_engine_recover_synchro(row);          diag_set(ClientError, ER_UNKNOWN_REQUEST_TYPE,               (uint32_t) row->type);          return -1; @@ -561,7 +561,7 @@ struct checkpoint {      struct vclock vclock;      struct xdir dir;      struct raft_request raft; -    struct synchro_request promote; +    struct synchro_request synchro_state;      /**       * Do nothing, just touch the snapshot file - the       * checkpoint already exists. @@ -587,7 +587,7 @@ checkpoint_new(const char *snap_dirname, uint64_t snap_io_rate_limit)      xdir_create(&ckpt->dir, snap_dirname, SNAP, &INSTANCE_UUID, &opts);      vclock_create(&ckpt->vclock);      box_raft_checkpoint_local(&ckpt->raft); -    txn_limbo_checkpoint(&txn_limbo, &ckpt->promote); +    txn_limbo_checkpoint(&txn_limbo, &ckpt->synchro_state);      ckpt->touch = false;      return ckpt;  } @@ -677,14 +677,12 @@ finish:  }  static int -checkpoint_write_promote(struct xlog *l, const struct synchro_request *req) +checkpoint_write_synchro(struct xlog *l, const struct synchro_request *req)  {      struct xrow_header row;      char body[XROW_SYNCHRO_BODY_LEN_MAX];      xrow_encode_synchro(&row, body, req); -    if (checkpoint_write_row(l, &row) != 0) -        return -1; -    return 0; +    return checkpoint_write_row(l, &row);  }  static int @@ -724,7 +722,7 @@ checkpoint_f(va_list ap)      }      if (checkpoint_write_raft(&snap, &ckpt->raft) != 0)          goto fail; -    if (checkpoint_write_promote(&snap, &ckpt->promote) != 0) +    if (checkpoint_write_synchro(&snap, &ckpt->synchro_state) != 0)          goto fail;      if (xlog_flush(&snap) < 0)          goto fail; diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c index 57f105ee3..c4ff5cc34 100644 --- a/src/box/txn_limbo.c +++ b/src/box/txn_limbo.c @@ -297,7 +297,8 @@ complete:  }  void -txn_limbo_checkpoint(struct txn_limbo *limbo, struct synchro_request *req) +txn_limbo_checkpoint(const struct txn_limbo *limbo, +             struct synchro_request *req)  {      req->type = IPROTO_PROMOTE;      req->replica_id = limbo->owner_id; diff --git a/src/box/txn_limbo.h b/src/box/txn_limbo.h index 84a19bb40..f5079d577 100644 --- a/src/box/txn_limbo.h +++ b/src/box/txn_limbo.h @@ -315,7 +315,8 @@ txn_limbo_wait_confirm(struct txn_limbo *limbo);   * Persist limbo state to a given synchro request.   */  void -txn_limbo_checkpoint(struct txn_limbo *limbo, struct synchro_request *req); +txn_limbo_checkpoint(const struct txn_limbo *limbo, +             struct synchro_request *req);  /**   * Write a PROMOTE request, which has the same effect as CONFIRM(@a lsn) and ================================== -- Serge Petrenko