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

Steams: XGROUP CREATE requires stream to exist #4824

adamcharnock opened this Issue Apr 8, 2018 · 6 comments


None yet
7 participants

adamcharnock commented Apr 8, 2018

I'm working on adding streams support to aioredis. It appears that using XGROUP CREATE with stream key that does not exist results in an ERR no such key.

I propose that either:

  1. XGROUP CREATE should create the key if it does not exist, or
  2. There should be way to create an empty stream without having to use XADD (which, AFAIK, there is not right now)


In the library I am creating it is quite possible that a process will wish to listen on a stream before the stream has received any messages. This is because the process reasonably expects a message to appear in the future.

From what I can see the current implementation does not support this. A somewhat cumbersome workaround would be to add a noop message to the stream.

Thank you for all the excellent work on streams, I'm really looking forward to the release.


This comment has been minimized.

mp911de commented Apr 12, 2018

Same here. Would be good to either implicitly create a key with XGROUP CREATE.

Creating an empty stream (Via a XADD for an empty stream) contradicts somewhat with Redis notion of empty/absence. Empty lists/sets are not listed via KEYS/SCAN.

Looking from an ops perspective, group creation could be a task done by operators which are not necessarily involved in stream/message creation.


This comment has been minimized.

dremekie commented Apr 24, 2018

Agreed. The ability to create an empty stream (#4833) would be great.


This comment has been minimized.


0xtonyxia commented May 28, 2018

Hi @antirez , please spare your time checking this issue and related PR if it's reasonable to support creating an empty stream directly using xadd command. Thanks.


This comment has been minimized.

MaerF0x0 commented Aug 3, 2018

It looks like you cannot do an empty XADD, but you could use a sentry value like:

XADD mystream * messageType sentry

And then just ignore sentry messages in the consumers.

Its a bit messier than adding XCREATE


This comment has been minimized.

hlavacek commented Nov 13, 2018

Hi, when you try the XGROUP CREATE command inside the redis cli on nonexisting stream, it will actually give you a hint that you can use MKSTREAM option to create the stream:

redis:6379> XGROUP CREATE tst tst_group $
(error) ERR The XGROUP subcommand requires the key to exist. Note that for CREATE you may want to use the MKSTREAM option to create an empty stream automatically.
redis:6379> XGROUP CREATE tst tst_group $ MKSTREAM

This comment has been minimized.


itamarhaber commented Nov 13, 2018

Indeed - the MKSTREAM option was introduced just before GA and is currently not documented (antirez/redis-doc#1007).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment