Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] The limit option of the xtrim command is invalid? #9046

Closed
monkey92t opened this issue Jun 4, 2021 · 3 comments
Closed

[BUG] The limit option of the xtrim command is invalid? #9046

monkey92t opened this issue Jun 4, 2021 · 3 comments

Comments

@monkey92t
Copy link

monkey92t commented Jun 4, 2021

127.0.0.1:6379> hello 3
1# "server" => "redis"
2# "version" => "6.2.1"
3# "proto" => (integer) 3
4# "id" => (integer) 2437
5# "mode" => "standalone"
6# "role" => "master"
7# "modules" => (empty array)
127.0.0.1:6379> 
127.0.0.1:6379> 
127.0.0.1:6379> xrange stream - + 
1) 1) "1-0"
   2) 1) "x1"
      2) "x2"
2) 1) "2-0"
   2) 1) "y1"
      2) "y2"
3) 1) "3-0"
   2) 1) "z1"
      2) "z2"
127.0.0.1:6379> 
127.0.0.1:6379> xtrim stream maxlen ~ 0 limit 2
(integer) 3
127.0.0.1:6379> 

limit 2 didn't work, all data was still removed ( return (integer) 3 ), or is my understanding of the limit option wrong?

@huangzhw
Copy link
Collaborator

huangzhw commented Jun 4, 2021

I think it's a bug. I wil try to fix it.

@guybe7
Copy link
Collaborator

guybe7 commented Jun 4, 2021

@monkey92t @huangzhw indeed a bug... thanks (discussion will continue in the PR)

oranagra pushed a commit that referenced this issue Jun 7, 2021
The decision to stop trimming due to LIMIT in XADD and XTRIM was after the limit was reached.
i.e. the code was deleting **at least** that count of records (from the LIMIT argument's perspective, not the MAXLEN),
instead of **up to** that count of records.
see #9046
@huangzhw
Copy link
Collaborator

huangzhw commented Jun 7, 2021

Fixed in #9048

@huangzhw huangzhw closed this as completed Jun 7, 2021
oranagra pushed a commit to oranagra/redis that referenced this issue Jul 20, 2021
…is#9048)

The decision to stop trimming due to LIMIT in XADD and XTRIM was after the limit was reached.
i.e. the code was deleting **at least** that count of records (from the LIMIT argument's perspective, not the MAXLEN),
instead of **up to** that count of records.
see redis#9046

(cherry picked from commit eaa7a7b)
oranagra pushed a commit that referenced this issue Jul 21, 2021
The decision to stop trimming due to LIMIT in XADD and XTRIM was after the limit was reached.
i.e. the code was deleting **at least** that count of records (from the LIMIT argument's perspective, not the MAXLEN),
instead of **up to** that count of records.
see #9046

(cherry picked from commit eaa7a7b)
JackieXie168 pushed a commit to JackieXie168/redis that referenced this issue Sep 8, 2021
…is#9048)

The decision to stop trimming due to LIMIT in XADD and XTRIM was after the limit was reached.
i.e. the code was deleting **at least** that count of records (from the LIMIT argument's perspective, not the MAXLEN),
instead of **up to** that count of records.
see redis#9046
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants