Skip to content

Commit

Permalink
wal: warn when trying to write a record with a broken lsn
Browse files Browse the repository at this point in the history
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
attempt to write a record with a duplicate or otherwise broken lsn, and
not follow such an lsn.

Follow-up #4739
  • Loading branch information
sergepetrenko authored and kyukhin committed Mar 2, 2020
1 parent 7b83b73 commit e075026
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/box/wal.c
Expand Up @@ -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);
}
}
}
}
Expand Down

0 comments on commit e075026

Please sign in to comment.