Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: kostja@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [PATCH 2/4] vinyl: fix lost key on dump completion
Date: Tue, 15 May 2018 17:08:38 +0300	[thread overview]
Message-ID: <b6c81d68e19062397a92e78fea62d2964e2bc688.1526392563.git.vdavydov.dev@gmail.com> (raw)
In-Reply-To: <cover.1526392563.git.vdavydov.dev@gmail.com>
In-Reply-To: <cover.1526392563.git.vdavydov.dev@gmail.com>

vy_task_dump_complete() creates a slice per each range overlapping with
the newly written run. It uses vy_range_tree_psearch(min_key) to find
the first overlapping range and nsearch(max_key) to find the range
immediately following the last overlapping range. This is incorrect as
nsearch rb tree method returns the element matching the search key if it
is present in the tree. That is, if the max key written to a run turns
out to be equal the beginning of a range, the slice won't be created for
it and it will be silently and persistently lost.

The issue manifests itself as crash in vinyl_iterator_secondary_next(),
when we fail to find the tuple in the primary index corresponding to a
statement found in a secondary index.

Part of #3393
---
 src/box/vy_scheduler.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/box/vy_scheduler.c b/src/box/vy_scheduler.c
index 912d9028..b76db587 100644
--- a/src/box/vy_scheduler.c
+++ b/src/box/vy_scheduler.c
@@ -741,7 +741,8 @@ vy_task_dump_complete(struct vy_scheduler *scheduler, struct vy_task *task)
 		goto fail;
 	}
 	begin_range = vy_range_tree_psearch(lsm->tree, min_key);
-	end_range = vy_range_tree_nsearch(lsm->tree, max_key);
+	end_range = vy_range_tree_psearch(lsm->tree, max_key);
+	end_range = vy_range_tree_next(lsm->tree, end_range);
 	tuple_unref(min_key);
 	tuple_unref(max_key);
 
-- 
2.11.0

  parent reply	other threads:[~2018-05-15 14:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-15 14:08 [PATCH 0/4] vinyl: fix crash in vinyl_iterator_secondary_next() Vladimir Davydov
2018-05-15 14:08 ` [PATCH 1/4] vinyl: fix EQ check in run iterator Vladimir Davydov
2018-05-15 19:05   ` Konstantin Osipov
2018-05-15 19:23     ` Vladimir Davydov
2018-05-15 14:08 ` Vladimir Davydov [this message]
2018-05-15 19:20   ` [PATCH 2/4] vinyl: fix lost key on dump completion Konstantin Osipov
2018-05-15 19:27     ` Vladimir Davydov
2018-05-15 14:08 ` [PATCH 3/4] vinyl: do not panic if secondary index is inconsistent with primary Vladimir Davydov
2018-05-15 14:08 ` [PATCH 4/4] test: improve vinyl/select_consistency Vladimir Davydov

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=b6c81d68e19062397a92e78fea62d2964e2bc688.1526392563.git.vdavydov.dev@gmail.com \
    --to=vdavydov.dev@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH 2/4] vinyl: fix lost key on dump completion' \
    /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