From: Serge Petrenko <sergepetrenko@tarantool.org> To: kostja.osipov@gmail.com, v.shpilevoy@tarantool.org Cc: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH v5 1/4] vclock: add an ability to reset individual clock components Date: Mon, 30 Mar 2020 14:04:08 +0300 [thread overview] Message-ID: <3162d52a68b95a43a0756dd2e03e4418dd80eafa.1585565637.git.sergepetrenko@tarantool.org> (raw) In-Reply-To: <cover.1585565637.git.sergepetrenko@tarantool.org> Anonymous replicas use 0th vclock component to sign local rows. vclock_reset will allow to zero-out 0th vclock component when an anonymous replica is promoted to a normal one and sends out its vclock to other joining instances, as to not pollute their own 0th vclock component. Also add a shortcut for vclcok_copy() + vclock_reset() for 0th clock component: vclock_copy_ignore0() Follow-up #3186 Prerequisite #4114 --- src/box/vclock.c | 15 +++++++++++++++ src/box/vclock.h | 24 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/box/vclock.c b/src/box/vclock.c index 90ae27591..ac3e9fccd 100644 --- a/src/box/vclock.c +++ b/src/box/vclock.c @@ -37,6 +37,21 @@ #include "diag.h" #include "tt_static.h" +void +vclock_reset(struct vclock *vclock, uint32_t replica_id, int64_t lsn) +{ + assert(lsn >= 0); + assert(replica_id < VCLOCK_MAX); + vclock->signature -= vclock_get(vclock, replica_id); + if (lsn == 0) { + vclock->map &= ~(1 << replica_id); + return; + } + vclock->lsn[replica_id] = lsn; + vclock->map |= 1 << replica_id; + vclock->signature += lsn; +} + int64_t vclock_follow(struct vclock *vclock, uint32_t replica_id, int64_t lsn) { diff --git a/src/box/vclock.h b/src/box/vclock.h index 79e5a1bc0..2a3a29020 100644 --- a/src/box/vclock.h +++ b/src/box/vclock.h @@ -182,6 +182,19 @@ vclock_inc(struct vclock *vclock, uint32_t replica_id) return ++vclock->lsn[replica_id]; } +/** + * Set vclock component represented by replica id to the desired + * value. Can be used to decrease stored LSN value for the given + * replica id while maintaining a valid signature or in the same + * manner as vclock_follow. + * + * @param vclock Vector clock. + * @param replica_id Replica identifier. + * @param lsn Lsn to set + */ +void +vclock_reset(struct vclock *vclock, uint32_t replica_id, int64_t lsn); + static inline void vclock_copy(struct vclock *dst, const struct vclock *src) { @@ -194,6 +207,17 @@ vclock_copy(struct vclock *dst, const struct vclock *src) sizeof(*dst->lsn) * max_pos); } +/** + * A shortcut for vclock_copy() + vclock_reset() for 0th clock + * component. + */ +static inline void +vclock_copy_ignore0(struct vclock *dst, const struct vclock *src) +{ + vclock_copy(dst, src); + vclock_reset(dst, 0, 0); +} + static inline uint32_t vclock_size(const struct vclock *vclock) { -- 2.21.1 (Apple Git-122.3)
next prev parent reply other threads:[~2020-03-30 11:04 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-03-30 11:04 [Tarantool-patches] [PATCH v5 0/4] replication: fix local space tracking Serge Petrenko 2020-03-30 11:04 ` Serge Petrenko [this message] 2020-03-30 12:56 ` [Tarantool-patches] [PATCH v5 1/4] vclock: add an ability to reset individual clock components Konstantin Osipov 2020-04-04 20:51 ` Vladislav Shpilevoy 2020-04-06 8:39 ` Konstantin Osipov 2020-04-07 11:48 ` Serge Petrenko 2020-03-30 11:04 ` [Tarantool-patches] [PATCH v5 2/4] replication: hide 0-th vclock components in replication responses Serge Petrenko 2020-03-30 12:56 ` Konstantin Osipov 2020-04-04 20:51 ` Vladislav Shpilevoy 2020-04-06 8:38 ` Konstantin Osipov 2020-04-07 12:22 ` Serge Petrenko 2020-03-30 11:04 ` [Tarantool-patches] [PATCH v5 3/4] gc: rely on minimal vclock components instead of signatures Serge Petrenko 2020-03-30 12:57 ` Konstantin Osipov 2020-04-04 20:51 ` Vladislav Shpilevoy 2020-04-07 12:40 ` Serge Petrenko 2020-03-30 11:04 ` [Tarantool-patches] [PATCH v5 4/4] box: start counting local space requests separately Serge Petrenko 2020-03-30 12:58 ` Konstantin Osipov 2020-04-04 20:51 ` Vladislav Shpilevoy 2020-04-07 15:48 ` Serge Petrenko 2020-03-31 11:24 ` [Tarantool-patches] [PATCH v5 0/4] replication: fix local space tracking Serge Petrenko 2020-04-04 20:51 ` Vladislav Shpilevoy 2020-04-07 11:15 ` Serge Petrenko
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=3162d52a68b95a43a0756dd2e03e4418dd80eafa.1585565637.git.sergepetrenko@tarantool.org \ --to=sergepetrenko@tarantool.org \ --cc=kostja.osipov@gmail.com \ --cc=tarantool-patches@dev.tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v5 1/4] vclock: add an ability to reset individual clock components' \ /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