TS.REVRANGE strange behaviour

127.0.0.1:6379> ts.range 1s:UBPpK:c - +
1) 1) (integer) 1595253343000
   2) "20.545000000000002"
2) 1) (integer) 1595253378000
   2) "20.495000000000001"
3) 1) (integer) 1595258359000
   2) "20.5199"
4) 1) (integer) 1595339163000
   2) "21.2499"
5) 1) (integer) 1595348755000
   2) "20.566800000000001"
6) 1) (integer) 1595352386000
   2) "20.550000000000001"
127.0.0.1:6379> ts.revrange 1s:UBPpK:c - +
1) 1) (integer) 1595430993000
   2) "20.100000000000001"
2) 1) (integer) 1595352386000
   2) "20.550000000000001"
3) 1) (integer) 1595348755000
   2) "20.566800000000001"
4) 1) (integer) 1595339163000
   2) "21.2499"
5) 1) (integer) 1595258359000
   2) "20.5199"

Is this not normal or is there something I am not understanding about the reverse commands? Isn’t it supposed to give me the same result as the range command but reversed? The reason I am even thinking about using reverse commands is that the COUNT parameter returns the first N items rather than the last N items. I’m kinda surprised me that there is a parameter for returning the Last N items, it would see a lot more use than the COUNT one (in my opinion).

Cheers

Hello,

Which version are you using? (I cannot reproduce it on my instance)

Using docker run -p 6379:6379 -it --rm redislabs/redistimeseries:1.4.2), the
ts.range and ts.revrange are sorting using the timestamp ascending/descending as you expect.

Using more or less the same data (I have change the value to make it easier to read)

Adding all data: (with the same timestamp that you have listed)

TS.ADD 1s:UBPpK:c 1595253343000  1

TS.ADD 1s:UBPpK:c 1595253378000 2

TS.ADD 1s:UBPpK:c 1595258359000 3

TS.ADD 1s:UBPpK:c 1595339163000 4

TS.ADD 1s:UBPpK:c 1595348755000 5

TS.ADD 1s:UBPpK:c 1595352386000 6

Querying:

127.0.0.1:6379> clear
127.0.0.1:6379> ts.range 1s:UBPpK:c - +
1) 1) (integer) 1595253343000
   2) 1
2) 1) (integer) 1595253378000
   2) 2
3) 1) (integer) 1595258359000
   2) 3
4) 1) (integer) 1595339163000
   2) 4
5) 1) (integer) 1595348755000
   2) 5
6) 1) (integer) 1595352386000
   2) 6
127.0.0.1:6379> ts.revrange 1s:UBPpK:c - +
1) 1) (integer) 1595352386000
   2) 6
2) 1) (integer) 1595348755000
   2) 5
3) 1) (integer) 1595339163000
   2) 4
4) 1) (integer) 1595258359000
   2) 3
5) 1) (integer) 1595253378000
   2) 2
6) 1) (integer) 1595253343000
   2) 1

Regards
Tug

I am running a 2 month old redismod:edge version. If you show me how I can see which version I have I will post it back to you. But it might not matter, if its fixed in the latest edge release (or any stable release that has all Redis modules) I will just pull that one.

Hi

If you run from edge the version does not have a real release number; it will be 9999 with the commit id.

And as you guess being “edge” on master it is subject to have bugs so you should probably update your image. (1.4.2 for example)

However to know the version, run:

> MODULE LIST

This will list the version of all the modules with the following format:

127.0.0.1:6379> MODULE LIST
1) 1) "name"
   2) "timeseries"
   3) "ver"
   4) (integer) 999999

It is also visible when you start Redis

...
1:M 23 Jul 2020 12:37:33.864 * <timeseries> RedisTimeSeries version 999999, git_sha=ca0d4a240c42da988b315b1c83d790a82984ca46
1:M 23 Jul 2020 12:37:33.865 * <timeseries> Redis version found by RedisTimeSeries : 6.0.5 - oss
...

When I run the 1.4.2 tag:

docker run -p 6379:6379 -it --rm redislabs/redistimeseries:1.4.2

1:M 23 Jul 2020 12:40:31.394 * <timeseries> RedisTimeSeries version 10402, git_sha=a47a05938158c2e5946242b11cca9e89b93de8a1
1:M 23 Jul 2020 12:40:31.394 * <timeseries> Redis version found by RedisTimeSeries : 6.0.5 - oss

and

127.0.0.1:6379> MODULE LIST
1) 1) "name"
   2) "timeseries"
   3) "ver"
   4) (integer) 10402

Version 10402 stands for 1.4.2

Regards
Tug

Alright, thanks

I will pull the latest image using docker pull redislabs/redismod and I will post again if I get the same issue.

Cheers