From: Serge Petrenko <sergepetrenko@tarantool.org> To: v.shpilevoy@tarantool.org, kostja.osipov@gmail.com Cc: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH v4 2/4] replication: hide 0-th vclock components in replication responses Date: Fri, 27 Mar 2020 13:20:37 +0300 [thread overview] Message-ID: <56c1a9001fafcd7525fdd3c6a68be2760b095532.1585303629.git.sergepetrenko@tarantool.org> (raw) In-Reply-To: <cover.1585303629.git.sergepetrenko@tarantool.org> 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. Follow-up #3186 Prerequisite #4114 --- src/box/applier.cc | 5 ++++- src/box/box.cc | 12 ++++++++++-- src/box/relay.cc | 8 ++++++-- test/replication/anon.result | 5 +++++ test/replication/anon.test.lua | 2 ++ 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/box/applier.cc b/src/box/applier.cc index 47a26c366..2e765ca12 100644 --- a/src/box/applier.cc +++ b/src/box/applier.cc @@ -173,7 +173,10 @@ applier_writer_f(va_list ap) continue; try { struct xrow_header xrow; - xrow_encode_vclock(&xrow, &replicaset.vclock); + struct vclock vclock; + vclock_copy(&vclock, &replicaset.vclock); + vclock_reset(&vclock, 0, 0); + 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 765d64678..87e836432 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -1540,6 +1540,7 @@ box_process_fetch_snapshot(struct ev_io *io, struct xrow_header *header) /* Remember master's vclock after the last request */ struct vclock stop_vclock; vclock_copy(&stop_vclock, &replicaset.vclock); + vclock_reset(&stop_vclock, 0, 0); /* Send end of snapshot data marker */ struct xrow_header row; @@ -1621,7 +1622,9 @@ box_process_register(struct ev_io *io, struct xrow_header *header) struct xrow_header row; /* Send end of WAL stream marker */ - xrow_encode_vclock_xc(&row, &replicaset.vclock); + vclock_copy(&vclock, &replicaset.vclock); + vclock_reset(&vclock, 0, 0); + xrow_encode_vclock_xc(&row, &vclock); row.sync = header->sync; coio_write_xrow(io, &row); @@ -1773,7 +1776,11 @@ box_process_join(struct ev_io *io, struct xrow_header *header) say_info("final data sent."); /* Send end of WAL stream marker */ - xrow_encode_vclock_xc(&row, &replicaset.vclock); + struct vclock vclock; + vclock_copy(&vclock, &replicaset.vclock); + vclock_reset(&vclock, 0, 0); + xrow_encode_vclock_xc(&row, &vclock); + row.sync = header->sync; coio_write_xrow(io, &row); @@ -1905,6 +1912,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); } /** Insert a new cluster into _schema */ diff --git a/src/box/relay.cc b/src/box/relay.cc index c634348a4..9abf35fdf 100644 --- a/src/box/relay.cc +++ b/src/box/relay.cc @@ -322,7 +322,11 @@ relay_initial_join(int fd, uint64_t sync, struct vclock *vclock) /* Respond to the JOIN request with the current vclock. */ struct xrow_header row; - xrow_encode_vclock_xc(&row, vclock); + struct vclock subst_vclock; + vclock_copy(&subst_vclock, vclock); + /* zero - out 0-th vclock component. */ + vclock_reset(&subst_vclock, 0, 0); + xrow_encode_vclock_xc(&row, &subst_vclock); row.sync = sync; coio_write_xrow(&relay->io, &row); @@ -464,7 +468,7 @@ relay_schedule_pending_gc(struct relay *relay, const struct vclock *vclock) * the greater signatures is due to changes pulled * from other members of the cluster. */ - if (vclock_compare(&curr->vclock, vclock) > 0) + if (vclock_compare_ignore0(&curr->vclock, vclock) > 0) break; stailq_shift(&relay->pending_gc); free(gc_msg); diff --git a/test/replication/anon.result b/test/replication/anon.result index 88061569f..cbbeeef09 100644 --- a/test/replication/anon.result +++ b/test/replication/anon.result @@ -187,6 +187,11 @@ a > 0 | --- | - true | ... +-- 0-th vclock component isn't propagated across the cluster. +box.info.vclock[0] + | --- + | - null + | ... test_run:cmd('switch default') | --- | - true diff --git a/test/replication/anon.test.lua b/test/replication/anon.test.lua index 8a8d15c18..627dc5c8e 100644 --- a/test/replication/anon.test.lua +++ b/test/replication/anon.test.lua @@ -66,6 +66,8 @@ test_run:cmd('switch replica_anon2') a = box.info.vclock[1] -- The instance did fetch a snapshot. a > 0 +-- 0-th vclock component isn't propagated across the cluster. +box.info.vclock[0] test_run:cmd('switch default') box.space.test:insert{2} test_run:cmd("switch replica_anon2") -- 2.21.1 (Apple Git-122.3)
next prev parent reply other threads:[~2020-03-27 10:20 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 ` Serge Petrenko [this message] 2020-03-28 5:57 ` [Tarantool-patches] [PATCH v4 2/4] replication: hide 0-th vclock components in replication responses Konstantin Osipov 2020-03-30 11:02 ` Serge Petrenko 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=56c1a9001fafcd7525fdd3c6a68be2760b095532.1585303629.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 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