From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Tue, 15 May 2018 22:20:43 +0300 From: Konstantin Osipov Subject: Re: [PATCH 2/4] vinyl: fix lost key on dump completion Message-ID: <20180515192043.GB24119@atlas> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: To: Vladimir Davydov Cc: tarantool-patches@freelists.org List-ID: * Vladimir Davydov [18/05/15 17:10]: I rebased the patch to 1.9, added a comment and pushed the patch. Once again, a separate unit test for this edge case would be greatly appreciated. > 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 -- Konstantin Osipov, Moscow, Russia, +7 903 626 22 32 http://tarantool.io - www.twitter.com/kostja_osipov