From: Serge Petrenko via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>, gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH 4/7] txn_limbo: persist the latest effective promote in snapshot Date: Fri, 18 Jun 2021 00:00:14 +0300 [thread overview] Message-ID: <ab09e1c6-0111-7fb7-7b53-026ee8551fd0@tarantool.org> (raw) In-Reply-To: <3fa9f126-3205-ef6e-c25c-d58a26677adf@tarantool.org> 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
next prev parent reply other threads:[~2021-06-17 21:01 UTC|newest] Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-06-10 13:32 [Tarantool-patches] [PATCH 0/7] forbid implicit limbo ownership transition Serge Petrenko via Tarantool-patches 2021-06-10 13:32 ` [Tarantool-patches] [PATCH 1/7] replication: always send raft state to subscribers Serge Petrenko via Tarantool-patches 2021-06-10 16:47 ` Cyrill Gorcunov via Tarantool-patches 2021-06-11 8:43 ` Serge Petrenko via Tarantool-patches 2021-06-11 8:44 ` Cyrill Gorcunov via Tarantool-patches 2021-06-15 20:53 ` Vladislav Shpilevoy via Tarantool-patches 2021-06-17 21:00 ` Serge Petrenko via Tarantool-patches 2021-06-10 13:32 ` [Tarantool-patches] [PATCH 2/7] replication: forbid implicit limbo owner transition Serge Petrenko via Tarantool-patches 2021-06-15 20:55 ` Vladislav Shpilevoy via Tarantool-patches 2021-06-17 21:00 ` Serge Petrenko via Tarantool-patches 2021-06-18 22:49 ` Vladislav Shpilevoy via Tarantool-patches 2021-06-21 10:13 ` Serge Petrenko via Tarantool-patches 2021-06-10 13:32 ` [Tarantool-patches] [PATCH 3/7] txn_limbo: fix promote term filtering Serge Petrenko via Tarantool-patches 2021-06-15 20:57 ` Vladislav Shpilevoy via Tarantool-patches 2021-06-17 21:00 ` Serge Petrenko via Tarantool-patches 2021-06-18 22:49 ` Vladislav Shpilevoy via Tarantool-patches 2021-06-21 8:55 ` Serge Petrenko via Tarantool-patches 2021-06-10 13:32 ` [Tarantool-patches] [PATCH 4/7] txn_limbo: persist the latest effective promote in snapshot Serge Petrenko via Tarantool-patches 2021-06-15 20:59 ` Vladislav Shpilevoy via Tarantool-patches 2021-06-17 21:00 ` Serge Petrenko via Tarantool-patches [this message] 2021-06-10 13:32 ` [Tarantool-patches] [PATCH 5/7] replication: send latest effective promote in initial join Serge Petrenko via Tarantool-patches 2021-06-15 21:00 ` Vladislav Shpilevoy via Tarantool-patches 2021-06-17 21:00 ` Serge Petrenko via Tarantool-patches 2021-06-18 22:52 ` Vladislav Shpilevoy via Tarantool-patches 2021-06-21 10:12 ` Serge Petrenko via Tarantool-patches 2021-06-10 13:32 ` [Tarantool-patches] [PATCH 6/7] box: introduce `box.ctl.demote` Serge Petrenko via Tarantool-patches 2021-06-18 22:52 ` Vladislav Shpilevoy via Tarantool-patches 2021-06-21 14:56 ` Serge Petrenko via Tarantool-patches 2021-06-10 13:32 ` [Tarantool-patches] [PATCH 7/7] box: make promote/demote always bump the term Serge Petrenko via Tarantool-patches 2021-06-15 21:00 ` Vladislav Shpilevoy via Tarantool-patches 2021-06-17 21:00 ` Serge Petrenko via Tarantool-patches 2021-06-18 22:53 ` Vladislav Shpilevoy via Tarantool-patches 2021-06-21 15:02 ` Serge Petrenko via Tarantool-patches 2021-06-15 20:53 ` [Tarantool-patches] [PATCH 0/7] forbid implicit limbo ownership transition Vladislav Shpilevoy via Tarantool-patches
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=ab09e1c6-0111-7fb7-7b53-026ee8551fd0@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=gorcunov@gmail.com \ --cc=sergepetrenko@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 4/7] txn_limbo: persist the latest effective promote in snapshot' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox