From: Serge Petrenko <sergepetrenko@tarantool.org> To: Konstantin Osipov <kostja.osipov@gmail.com> Cc: tarantool-patches@dev.tarantool.org, Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH v4 2/4] replication: hide 0-th vclock components in replication responses Date: Mon, 30 Mar 2020 14:02:46 +0300 [thread overview] Message-ID: <1A4735AC-A4B1-4CEA-AC0E-0CA173EFDECE@tarantool.org> (raw) In-Reply-To: <20200328055744.GA23207@atlas> > 28 марта 2020 г., в 08:57, Konstantin Osipov <kostja.osipov@gmail.com> написал(а): > > * Serge Petrenko <sergepetrenko@tarantool.org> [20/03/27 18:08]: >> If an anonymous replica is promoted to a normal one and becomes >> replication master later, its vclock contains a non-empty zero >> component, tracking local changes on this replica from the time when it >> had been anonymous. No need to pollute joining instance's vclock with >> our non-empty 0 component. >> When an anonymous replica reports its status to a remote instance it >> should also hide its 0-th vclock component. >> >> This is needed for backward compatibility with old instances, which >> don't ignore 0th vclock component coming from a remote instance by >> default. >> Also make sure that new instances ignore 0th vclock component. > > If you added vclock_compare_ignore0, suggest to introduce and use > vclock_copy_ignore0 instead of a pair vclock_copy + vclock_reset. Ok. The diff’s below. > > Where was vclock_compare_ignore0 introduced, did I miss the > patch? I added it in one of the anonymous replica patches. ============================================================= 1st patch: diff --git a/src/box/vclock.h b/src/box/vclock.h index aeb8ca66b..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) { @@ -211,19 +235,6 @@ vclock_calc_sum(const struct vclock *vclock) return sum; } -/** - * 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 int64_t vclock_sum(const struct vclock *vclock) { ============================================================================ 2nd patch: diff --git a/src/box/applier.cc b/src/box/applier.cc index 2e765ca12..f5f67b6a9 100644 --- a/src/box/applier.cc +++ b/src/box/applier.cc @@ -174,8 +174,7 @@ applier_writer_f(va_list ap) try { struct xrow_header xrow; struct vclock vclock; - vclock_copy(&vclock, &replicaset.vclock); - vclock_reset(&vclock, 0, 0); + vclock_copy_ignore0(&vclock, &replicaset.vclock); xrow_encode_vclock(&xrow, &vclock); coio_write_xrow(&io, &xrow); } catch (SocketError *e) { diff --git a/src/box/box.cc b/src/box/box.cc index 87e836432..b49fdbe21 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -1622,8 +1622,7 @@ box_process_register(struct ev_io *io, struct xrow_header *header) struct xrow_header row; /* Send end of WAL stream marker */ - vclock_copy(&vclock, &replicaset.vclock); - vclock_reset(&vclock, 0, 0); + vclock_copy_ignore0(&vclock, &replicaset.vclock); xrow_encode_vclock_xc(&row, &vclock); row.sync = header->sync; coio_write_xrow(io, &row); @@ -1777,8 +1776,7 @@ box_process_join(struct ev_io *io, struct xrow_header *header) /* Send end of WAL stream marker */ struct vclock vclock; - vclock_copy(&vclock, &replicaset.vclock); - vclock_reset(&vclock, 0, 0); + vclock_copy_ignore0(&vclock, &replicaset.vclock); xrow_encode_vclock_xc(&row, &vclock); row.sync = header->sync; @@ -1911,8 +1909,7 @@ box_process_vote(struct ballot *ballot) */ ballot->is_loading = is_ro; vclock_copy(&ballot->vclock, &replicaset.vclock); - vclock_copy(&ballot->gc_vclock, &gc.vclock); - vclock_reset(&ballot->gc_vclock, 0, 0); + vclock_copy_ignore0(&ballot->gc_vclock, &gc.vclock); } /** Insert a new cluster into _schema */ diff --git a/src/box/relay.cc b/src/box/relay.cc index 9abf35fdf..5ed8f5dae 100644 --- a/src/box/relay.cc +++ b/src/box/relay.cc @@ -323,9 +323,7 @@ relay_initial_join(int fd, uint64_t sync, struct vclock *vclock) /* Respond to the JOIN request with the current vclock. */ struct xrow_header row; struct vclock subst_vclock; - vclock_copy(&subst_vclock, vclock); - /* zero - out 0-th vclock component. */ - vclock_reset(&subst_vclock, 0, 0); + vclock_copy_ignore0(&subst_vclock, vclock); xrow_encode_vclock_xc(&row, &subst_vclock); row.sync = sync; coio_write_xrow(&relay->io, &row); > > -- > Konstantin Osipov, Moscow, Russia -- Serge Petrenko sergepetrenko@tarantool.org
next prev parent reply other threads:[~2020-03-30 11:02 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-03-27 10:20 [Tarantool-patches] [PATCH v4 0/4] replication: fix local space tracking Serge Petrenko 2020-03-27 10:20 ` [Tarantool-patches] [PATCH v4 1/4] vclock: add an ability to reset individual clock components Serge Petrenko 2020-03-27 10:20 ` [Tarantool-patches] [PATCH v4 2/4] replication: hide 0-th vclock components in replication responses Serge Petrenko 2020-03-28 5:57 ` Konstantin Osipov 2020-03-30 11:02 ` Serge Petrenko [this message] 2020-03-30 12:52 ` Konstantin Osipov 2020-03-27 10:20 ` [Tarantool-patches] [PATCH v4 3/4] gc: rely on minimal vclock components instead of signatures Serge Petrenko 2020-03-28 6:03 ` Konstantin Osipov 2020-03-30 11:02 ` Serge Petrenko 2020-03-30 12:54 ` Konstantin Osipov 2020-03-27 10:20 ` [Tarantool-patches] [PATCH v4 4/4] box: start counting local space requests separately Serge Petrenko 2020-03-28 6:17 ` Konstantin Osipov 2020-03-30 11:02 ` Serge Petrenko 2020-03-28 16:23 ` Konstantin Osipov
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=1A4735AC-A4B1-4CEA-AC0E-0CA173EFDECE@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 v4 2/4] replication: hide 0-th vclock components in replication responses' \ /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