Redis XADD: ERR Invalid stream ID specified as stream command argument

Why am I getting this error for xadd.

Redis: 6.2

127.0.0.1:6379> xadd hello 1658902141-* key val
(error) ERR Invalid stream ID specified as stream command argument
127.0.0.1:6379> xadd hello 1658902141000-* key val
(error) ERR Invalid stream ID specified as stream command argument
127.0.0.1:6379> XADD mystream 1526919030474-* message " World!"
(error) ERR Invalid stream ID specified as stream command argument

>Solution :

Event id with timestamp-* format, is a new feature of Redis-7.0. You should check your Redis version. If it’s an older version, you cannot use this feature.

If you want to achieve the goal, i.e. fix timestamp, while increase the counter, you have to do it on client side. Or use ‘*’ as ID, to make Redis automatically generating id with an increasing timestamp.

Leave a Reply