From 5b9e68df9910ebfdabcb331b33a07400c74073e7 Mon Sep 17 00:00:00 2001 From: martinsumner Date: Thu, 29 Dec 2016 03:04:10 +0000 Subject: [PATCH] Add some crash protection for empty return from to_range Not clear though why it would occur. --- src/leveled_sst.erl | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/leveled_sst.erl b/src/leveled_sst.erl index b81346d..a3f2ec1 100644 --- a/src/leveled_sst.erl +++ b/src/leveled_sst.erl @@ -672,18 +672,23 @@ lookup_slots_int(StartKey, all, SkipList) -> LTrim = FirstKey < StartKey, {RKeep0, LTrim, false}; lookup_slots_int(StartKey, EndKey, SkipList) -> - L0 = leveled_skiplist:to_range(SkipList, StartKey, EndKey), - {LastKey, _LastVal} = lists:last(L0), - case LastKey of - EndKey -> - {L0, true, false}; - _ -> - LTail = leveled_skiplist:key_above_notequals(SkipList, LastKey), - case LTail of - false -> + case leveled_skiplist:to_range(SkipList, StartKey, EndKey) of + [] -> + {[], false, false}; + L0 -> + {LastKey, _LastVal} = lists:last(L0), + case LastKey of + EndKey -> {L0, true, false}; _ -> - {L0 ++ [LTail], true, true} + LTail = leveled_skiplist:key_above_notequals(SkipList, + LastKey), + case LTail of + false -> + {L0, true, false}; + _ -> + {L0 ++ [LTail], true, true} + end end end.