From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 7BA724696C1 for ; Sun, 15 Dec 2019 23:59:00 +0300 (MSK) From: sergepetrenko Date: Sun, 15 Dec 2019 23:58:44 +0300 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 4/5] vclock: ignore 0th component in comparisons. List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: georgy@tarantool.org Cc: tarantool-patches@dev.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. --- src/box/vclock.h | 7 +++++++ test/unit/vclock.cc | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/box/vclock.h b/src/box/vclock.h index b5eddcf8b..5dddbd173 100644 --- a/src/box/vclock.h +++ b/src/box/vclock.h @@ -281,6 +281,13 @@ vclock_compare(const struct vclock *a, const struct vclock *b) for (size_t replica_id = bit_iterator_next(&it); replica_id < VCLOCK_MAX; 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) + continue; 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)