From 4ee10c155d753890e508596f65c8fb24140e1290 Mon Sep 17 00:00:00 2001 From: Badlop Date: Thu, 10 Jun 2021 20:21:44 +0200 Subject: [PATCH] Fix reverse order of items when using in Pubsub with RSM (#3621) --- src/node_flat.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node_flat.erl b/src/node_flat.erl index 5c34f5fdb..4a2a60971 100644 --- a/src/node_flat.erl +++ b/src/node_flat.erl @@ -758,12 +758,12 @@ get_items(Nidx, _From, #rsm_set{max = Max, index = IncIndex, {_, <<>>, undefined} -> %% 2.5 Requesting the Last Page in a Result Set SubList = lists:reverse(RItems), - {Count, lists:sublist(SubList, Limit)}; + {Count-Limit, lists:reverse(lists:sublist(SubList, Limit))}; {_, Stamp, undefined} -> BeforeNow = encode_stamp(Stamp), {NewIndex, SubList} = extract_sublist(before_now, BeforeNow, 0, lists:reverse(RItems)), - {Count-NewIndex-1, lists:sublist(SubList, Limit)}; + {Count-NewIndex-Limit, lists:reverse(lists:sublist(SubList, Limit))}; {_, undefined, Stamp} -> AfterNow = encode_stamp(Stamp), {NewIndex, SubList} = extract_sublist(after_now, AfterNow,