From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp50.i.mail.ru (smtp50.i.mail.ru [94.100.177.110]) (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 00A024696C3 for ; Fri, 14 Feb 2020 00:53:13 +0300 (MSK) From: sergepetrenko Date: Fri, 14 Feb 2020 00:52:59 +0300 Message-Id: <97f37279955ebc29e899164cc1364e6a0aea0f9b.1581630406.git.sergepetrenko@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v2 3/4] wal: wart when trying to write a record with a broken lsn List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: alexander.turenko@tarantool.org, v.shpilevoy@tarantool.org, kostja.osipov@gmail.com Cc: tarantool-patches@dev.tarantool.org From: Serge Petrenko 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. Follow-up #4739 --- src/box/wal.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/box/wal.c b/src/box/wal.c index 0ae66ff32..f8ee2b7d8 100644 --- a/src/box/wal.c +++ b/src/box/wal.c @@ -951,9 +951,18 @@ 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, committed lsn: %d," + " new lsn %d", (*row)->replica_id, + vclock_get(base, (*row)->replica_id) + + vclock_get(vclock_diff, + (*row)->replica_id), + (*row)->lsn); + } + vclock_follow(vclock_diff, (*row)->replica_id, diff); } } } -- 2.20.1 (Apple Git-117)