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

XREAD COUNT doesn't work with BLOCK #1450

Open
hlavacek opened this issue Nov 8, 2018 · 9 comments
Open

XREAD COUNT doesn't work with BLOCK #1450

hlavacek opened this issue Nov 8, 2018 · 9 comments

Comments

@hlavacek
Copy link

@hlavacek hlavacek commented Nov 8, 2018

The documentation for XREAD https://redis.io/commands/xread mentions that you can issue XREAD with BLOCK and COUNT like this:

> XREAD BLOCK 5000 COUNT 100 STREAMS mystream $

My expectation would be that this waits max 5 seconds, but also waits for 100 messages in the stream. But when trying the following:

XREAD BLOCK 20000 COUNT 100 STREAMS tst $

The command returns back in redis cli after first XADD, and does not wait 20 seconds for other messages:

XADD tst * sensor-id 1234 temperature 19.8
...
> XREAD BLOCK 20000 COUNT 100 STREAMS tst $
1) 1) "tst"
   2) 1) 1) "1541717154056-0"
         2) 1) "sensor-id"
            2) "1234"
            3) "temperature"
            4) "19.8"
(1.79s)

Is this the expected behaviour?
Tried in Docker redis 5.0

@hlavacek hlavacek changed the title XREAD BLOCK doesn't work with COUNT XREAD COUNT doesn't work with BLOCK Nov 8, 2018
@itamarhaber
Copy link
Collaborator

@itamarhaber itamarhaber commented Nov 8, 2018

Hello @hlavacek,

AFAIR, using BLOCK implicitly means COUNT 1 despite the docs' syntax.

@hlavacek
Copy link
Author

@hlavacek hlavacek commented Nov 8, 2018

At least a documentation issue then, same is true for XREADGROUP:

XREADGROUP GROUP mygroup asd COUNT 5 BLOCK 0 STREAMS mystream >
...
XADD mystream * sensor-id 1234 temperature 19
...
XREADGROUP GROUP mygroup asd COUNT 5 BLOCK 0 STREAMS mystream >
1) 1) "mystream"
   2) 1) 1) "1541719198549-0"
         2) 1) "sensor-id"
            2) "1234"
            3) "temperature"
            4) "19"
(2.90s)

@StasKolodyuk
Copy link

@StasKolodyuk StasKolodyuk commented Jun 7, 2019

@itamarhaber So is this the expected behaviour then?

@itamarhaber
Copy link
Collaborator

@itamarhaber itamarhaber commented Jun 7, 2019

Yes, that is the expected behavior.

If the stream has 1 and up to 'count' messages, the read will return immediately w/o blocking and with as many messages as possible. If there are no messages, the block comes into effect and is released and returned once there is one message it can read, basically immediately after the XADD

@StasKolodyuk
Copy link

@StasKolodyuk StasKolodyuk commented Jun 7, 2019

@itamarhaber thanks for clarification!

@dselivanov
Copy link

@dselivanov dselivanov commented Jul 18, 2019

case described in docs would be very interesting - wait COUNT records OR BLOCK seconds

@fubar
Copy link

@fubar fubar commented Dec 1, 2020

This needs to be described in the docs.

@itamarhaber
Copy link
Collaborator

@itamarhaber itamarhaber commented Dec 1, 2020

Would appreciate a PR to that effect :)

Anyway, since this is seemingly a doc issue, moving to the doc repo.

@itamarhaber itamarhaber transferred this issue from redis/redis Dec 1, 2020
@mrajancsr
Copy link

@mrajancsr mrajancsr commented Apr 18, 2022

this definitely needs to be described in the docs.

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

6 participants