From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH 2/4] vinyl: fix lost key on dump completion Date: Tue, 15 May 2018 17:08:38 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: 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