From: Georgy Kirichenko <georgy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Georgy Kirichenko <georgy@tarantool.org>
Subject: [tarantool-patches] [PATCH 5/5] Disallow lsn gaps while vclock following
Date: Fri, 4 Jan 2019 13:34:15 +0300 [thread overview]
Message-ID: <1b75f8d5ccd7474862a5812550cc68680ba1142e.1546593619.git.georgy@tarantool.org> (raw)
In-Reply-To: <cover.1546593619.git.georgy@tarantool.org>
Only one-step vclock following is allowed. This enforces wal and
replication consistency against out of order execution.
Needed for: #980
---
src/box/replication.cc | 1 +
src/box/vclock.c | 2 +-
src/box/xrow.c | 2 +-
test/unit/vclock.cc | 10 +++++-----
4 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/box/replication.cc b/src/box/replication.cc
index 51e08886c..ee92a941b 100644
--- a/src/box/replication.cc
+++ b/src/box/replication.cc
@@ -91,6 +91,7 @@ replication_init(void)
replicaset.replica_by_id = (struct replica **)calloc(VCLOCK_MAX, sizeof(struct replica *));
latch_create(&replicaset.applier.order_latch);
vclock_create(&replicaset.applier.vclock);
+ vclock_clear(&replicaset.applier.vclock);
}
void
diff --git a/src/box/vclock.c b/src/box/vclock.c
index c297d1ff9..807da9109 100644
--- a/src/box/vclock.c
+++ b/src/box/vclock.c
@@ -56,7 +56,7 @@ vclock_follow(struct vclock *vclock, uint32_t replica_id, int64_t lsn)
assert(lsn >= 0);
assert(replica_id < VCLOCK_MAX);
int64_t prev_lsn = vclock->lsn[replica_id];
- assert(lsn > prev_lsn);
+ assert(lsn == prev_lsn + 1);
/* Easier add each time than check. */
vclock->map |= 1 << replica_id;
vclock->lsn[replica_id] = lsn;
diff --git a/src/box/xrow.c b/src/box/xrow.c
index 67019a68d..ef3f81add 100644
--- a/src/box/xrow.c
+++ b/src/box/xrow.c
@@ -83,7 +83,7 @@ mp_decode_vclock(const char **data, struct vclock *vclock)
return -1;
int64_t lsn = mp_decode_uint(data);
if (lsn > 0)
- vclock_follow(vclock, id, lsn);
+ vclock_set(vclock, id, lsn);
}
return 0;
}
diff --git a/test/unit/vclock.cc b/test/unit/vclock.cc
index 8498eba3b..6a8d498ef 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_set(&a, node_id, 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_set(&b, node_id, 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_set(vclock, node_id, lsn);
}
vclockset_insert(set, vclock);
}
@@ -225,7 +225,7 @@ test_isearch()
if (lsn <= 0)
continue;
- vclock_follow(&vclock, node_id, lsn);
+ vclock_set(&vclock, node_id, lsn);
}
int64_t check = *(query + NODE_N);
@@ -247,7 +247,7 @@ test_tostring_one(uint32_t count, const int64_t *lsns, const char *res)
vclock_create(&vclock);
for (uint32_t node_id = 0; node_id < count; node_id++) {
if (lsns[node_id] > 0)
- vclock_follow(&vclock, node_id, lsns[node_id]);
+ vclock_set(&vclock, node_id, lsns[node_id]);
}
char *str = vclock_to_string(&vclock);
int result = strcmp(str, res);
--
2.20.1
next prev parent reply other threads:[~2019-01-04 10:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-04 10:34 [tarantool-patches] [PATCH 0/5] Strong sequentially LSN in journal Georgy Kirichenko
2019-01-04 10:34 ` [tarantool-patches] [PATCH 1/5] Do not promote wal vclock for failed writes Georgy Kirichenko
2019-01-04 10:34 ` [tarantool-patches] [PATCH 2/5] Update replicaset vclock from wal Georgy Kirichenko
2019-01-04 10:34 ` [tarantool-patches] [PATCH 3/5] Enforce applier out of order protection Georgy Kirichenko
2019-01-04 10:34 ` [tarantool-patches] [PATCH 4/5] Emit NOP if an applier skips row Georgy Kirichenko
2019-01-04 10:34 ` Georgy Kirichenko [this message]
2019-01-11 13:31 ` [tarantool-patches] Re: [PATCH 0/5] Strong sequentially LSN in journal Georgy Kirichenko
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=1b75f8d5ccd7474862a5812550cc68680ba1142e.1546593619.git.georgy@tarantool.org \
--to=georgy@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [tarantool-patches] [PATCH 5/5] Disallow lsn gaps while vclock following' \
/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