[Tarantool-patches] [PATCH v4 2/4] wal: warn when trying to write a record with a broken lsn
sergepetrenko
sergepetrenko at tarantool.org
Wed Feb 26 13:00:07 MSK 2020
From: Serge Petrenko <sergepetrenko at tarantool.org>
There is an assertion in vclock_follow `lsn > prev_lsn`, which doesn't
fire in release builds, of course. Let's at least warn the user on an
attemt to write a record with a duplicate or otherwise broken lsn, and
not follow such an lsn.
Follow-up #4739
---
src/box/wal.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/box/wal.c b/src/box/wal.c
index ac977c16e..27bff662a 100644
--- a/src/box/wal.c
+++ b/src/box/wal.c
@@ -951,9 +951,20 @@ wal_assign_lsn(struct vclock *vclock_diff, struct vclock *base,
(*row)->tsn = tsn;
(*row)->is_commit = row == end - 1;
} else {
- vclock_follow(vclock_diff, (*row)->replica_id,
- (*row)->lsn - vclock_get(base,
- (*row)->replica_id));
+ int64_t diff = (*row)->lsn - vclock_get(base, (*row)->replica_id);
+ if (diff <= vclock_get(vclock_diff,
+ (*row)->replica_id)) {
+ say_crit("Attempt to write a broken LSN to WAL:"
+ " replica id: %d, confirmed lsn: %d,"
+ " new lsn %d", (*row)->replica_id,
+ vclock_get(base, (*row)->replica_id) +
+ vclock_get(vclock_diff,
+ (*row)->replica_id),
+ (*row)->lsn);
+ assert(false);
+ } else {
+ vclock_follow(vclock_diff, (*row)->replica_id, diff);
+ }
}
}
}
--
2.20.1 (Apple Git-117)
More information about the Tarantool-patches
mailing list