Redis Stage #ZN8 Blocking reads

I’m stuck on stage 11 in redis streams extension
Here is my output.

[streams-11] Running tests for Streams > Stage #11: Blocking reads
[streams-11] $ ./
[streams-11] $ redis-cli xadd "blueberry" "0-1" "temperature 77"
[your_program] ('::1', 41958, 0, 0): b'*5\r\n$4\r\nxadd\r\n$9\r\nblueberry\r\n$3\r\n0-1\r\n$11\r\ntemperature\r\n$2\r\n77\r\n'
[your_program] received message b'*5\r\n$4\r\nxadd\r\n$9\r\nblueberry\r\n$3\r\n0-1\r\n$11\r\ntemperature\r\n$2\r\n77\r\n'
[your_program] parsed message: Message(parsed=['xadd', 'blueberry', '0-1', 'temperature', '77'], raw=b'*5\r\n$4\r\nxadd\r\n$9\r\nblueberry\r\n$3\r\n0-1\r\n$11\r\ntemperature\r\n$2\r\n77\r\n', size=64)
[your_program] send messages ['0-1']
[your_program] b'$3\r\n0-1\r\n'
[streams-11] Received response: ""0-1""
[streams-11] $ redis-cli xread block 'Ϩ' streams "blueberry 0-1"
[your_program] ('::1', 41958, 0, 0): b'*6\r\n$5\r\nxread\r\n$5\r\nblock\r\n$4\r\n1000\r\n$7\r\nstreams\r\n$9\r\nblueberry\r\n$3\r\n0-1\r\n'
[your_program] received message b'*6\r\n$5\r\nxread\r\n$5\r\nblock\r\n$4\r\n1000\r\n$7\r\nstreams\r\n$9\r\nblueberry\r\n$3\r\n0-1\r\n'
[your_program] parsed message: Message(parsed=['xread', 'block', '1000', 'streams', 'blueberry', '0-1'], raw=b'*6\r\n$5\r\nxread\r\n$5\r\nblock\r\n$4\r\n1000\r\n$7\r\nstreams\r\n$9\r\nblueberry\r\n$3\r\n0-1\r\n', size=73)
[streams-11] $ redis-cli xadd "blueberry" "0-2" "temperature 77"
[your_program] ('::1', 41964, 0, 0): b'*5\r\n$4\r\nxadd\r\n$9\r\nblueberry\r\n$3\r\n0-2\r\n$11\r\ntemperature\r\n$2\r\n77\r\n'
[your_program] received message b'*5\r\n$4\r\nxadd\r\n$9\r\nblueberry\r\n$3\r\n0-2\r\n$11\r\ntemperature\r\n$2\r\n77\r\n'
[your_program] parsed message: Message(parsed=['xadd', 'blueberry', '0-2', 'temperature', '77'], raw=b'*5\r\n$4\r\nxadd\r\n$9\r\nblueberry\r\n$3\r\n0-2\r\n$11\r\ntemperature\r\n$2\r\n77\r\n', size=64)
[streams-11] Received response: ""0-2""
[your_program] send messages ['0-2']
[your_program] b'$3\r\n0-2\r\n'
[your_program] send messages [['blueberry', [['0-1', ['temperature', '77']], ['0-2', ['temperature', '77']]]]]
[your_program] b'*2\r\n$9\r\nblueberry\r\n*2\r\n*2\r\n$3\r\n0-1\r\n*2\r\n$11\r\ntemperature\r\n$2\r\n77\r\n*2\r\n$3\r\n0-2\r\n*2\r\n$11\r\ntemperature\r\n$2\r\n77\r\n'
[streams-11] timed out, test exceeded 10 seconds
[streams-11] Test failed
[streams-11] Terminating program
[streams-11] Program terminated successfully

According to my log, I sent a response to the read request, but the test crashes after a while with the error Test failed. When I test manually, I get a response to the xread message immediately after the second xadd request. Here is my code GitHub - AlexeyVatolin/mini-redis: Implementation of redis main functions
Please help me figure out the problem

[‘xread’, ‘block’, ‘1000’, ‘streams’, ‘blueberry’, ‘0-1’]
Expected return should only include i larger than ‘0-1’ which is ‘0-2’.
For this test case, if your return message is not exactly expected, it would not error out, instead it would timeout after 10s.

1 Like

This helped me, thanks!

Note: I’ve updated the title of this post to include the stage ID (#ZN8). You can learn about the stages rename here: Upcoming change: Stages overhaul.