From: sergepetrenko <sergepetrenko@tarantool.org>
To: v.shpilevoy@tarantool.org, georgy@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH v2 4/5] vclock: ignore 0th component in comparisons.
Date: Wed, 25 Dec 2019 15:47:01 +0300 [thread overview]
Message-ID: <42999683415fb48efba3821b59ef7e62ad00cf16.1577277455.git.sergepetrenko@tarantool.org> (raw)
In-Reply-To: <cover.1577277455.git.sergepetrenko@tarantool.org>
From: Serge Petrenko <sergepetrenko@tarantool.org>
0th vclock component will be used to count replica-local rows of an
anonymous replica. These rows won't be replicated and different
instances will have different values in vclock[0]. So ignore 0th
component in comparisons.
Part of #3186
---
src/box/vclock.h | 12 ++++++++++--
test/unit/vclock.cc | 8 ++++----
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/box/vclock.h b/src/box/vclock.h
index b5eddcf8b..35ba6284c 100644
--- a/src/box/vclock.h
+++ b/src/box/vclock.h
@@ -279,8 +279,16 @@ vclock_compare(const struct vclock *a, const struct vclock *b)
struct bit_iterator it;
bit_iterator_init(&it, &map, sizeof(map), true);
- for (size_t replica_id = bit_iterator_next(&it); replica_id < VCLOCK_MAX;
- replica_id = bit_iterator_next(&it)) {
+ size_t replica_id = bit_iterator_next(&it);
+ /*
+ * Ignore 0-th component in comparisons.
+ * It is empty for normal replicas and should
+ * be ignored for anonymous ones.
+ */
+ if (replica_id == 0)
+ replica_id = bit_iterator_next(&it);
+
+ for (; replica_id < VCLOCK_MAX; replica_id = bit_iterator_next(&it)) {
int64_t lsn_a = vclock_get(a, replica_id);
int64_t lsn_b = vclock_get(b, replica_id);
diff --git a/test/unit/vclock.cc b/test/unit/vclock.cc
index 15e9f9379..d9f676a31 100644
--- a/test/unit/vclock.cc
+++ b/test/unit/vclock.cc
@@ -50,11 +50,11 @@ test_compare_one(uint32_t a_count, const int64_t *lsns_a,
vclock_create(&b);
for (uint32_t node_id = 0; node_id < a_count; node_id++) {
if (lsns_a[node_id] > 0)
- vclock_follow(&a, node_id, lsns_a[node_id]);
+ vclock_follow(&a, node_id + 1, lsns_a[node_id]);
}
for (uint32_t node_id = 0; node_id < b_count; node_id++) {
if (lsns_b[node_id] > 0)
- vclock_follow(&b, node_id, lsns_b[node_id]);
+ vclock_follow(&b, node_id + 1, lsns_b[node_id]);
}
return vclock_compare(&a, &b);
@@ -119,7 +119,7 @@ testset_create(vclockset_t *set, int64_t *files, int files_n, int node_n)
signature += lsn;
/* Update cluster hash */
- vclock_follow(vclock, node_id, lsn);
+ vclock_follow(vclock, node_id + 1, lsn);
}
vclockset_insert(set, vclock);
}
@@ -225,7 +225,7 @@ test_isearch()
if (lsn <= 0)
continue;
- vclock_follow(&vclock, node_id, lsn);
+ vclock_follow(&vclock, node_id + 1, lsn);
}
int64_t check = *(query + NODE_N);
--
2.20.1 (Apple Git-117)
next prev parent reply other threads:[~2019-12-25 12:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-25 12:46 [Tarantool-patches] [PATCH v2 0/5] introduce anonymous replicas sergepetrenko
2019-12-25 12:46 ` [Tarantool-patches] [PATCH v2 1/5] box: update comment describing join protocol sergepetrenko
2019-12-25 12:46 ` [Tarantool-patches] [PATCH v2 2/5] replication: do not decode replicaset uuid when processing a subscribe sergepetrenko
2019-12-25 12:47 ` [Tarantool-patches] [PATCH v2 3/5] applier: split join processing into two stages sergepetrenko
2019-12-25 12:47 ` sergepetrenko [this message]
2019-12-25 16:00 ` [Tarantool-patches] [PATCH v2 4/5] vclock: ignore 0th component in comparisons Vladislav Shpilevoy
2019-12-27 18:42 ` Vladislav Shpilevoy
2019-12-28 11:21 ` Sergey Petrenko
2019-12-25 12:47 ` [Tarantool-patches] [PATCH v2 5/5] replication: introduce anonymous replica sergepetrenko
2019-12-25 18:22 ` Vladislav Shpilevoy
2019-12-27 15:27 ` Sergey Petrenko
2019-12-27 18:42 ` Vladislav Shpilevoy
2019-12-28 11:48 ` Sergey Petrenko
2019-12-28 12:15 ` Vladislav Shpilevoy
2019-12-30 5:12 ` [Tarantool-patches] [PATCH v2 0/5] introduce anonymous replicas Kirill Yukhin
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=42999683415fb48efba3821b59ef7e62ad00cf16.1577277455.git.sergepetrenko@tarantool.org \
--to=sergepetrenko@tarantool.org \
--cc=georgy@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH v2 4/5] vclock: ignore 0th component in comparisons.' \
/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