hiredis icon indicating copy to clipboard operation
hiredis copied to clipboard

Add support for Redis 7's sharded pubsub commands

Open slact opened this issue 2 years ago • 4 comments

slact avatar May 17 '22 07:05 slact

As I understand, there is no difference between the MESSAGEs sent to subscribers from PUBLISH or SPUBLISH commands. Both send this to subscribers:

1) MESSAGE
2) <channel_name>
3) <message_data>

So if you use hiredis to SUBSCRIBE and also SSUBSCRIBE to channel "foo", when messages arrive it will be impossible to tell if it came from the sharded or the regular channel. While the pubsub and sharde-pubsub keyspaces are non-overlapping on the server-side, the protocol's failure to distinguish between the source of the message overlaps the keyspaces for the client.

By the way, I initially implemented this with a separate sub.sharded_channels dictionary for SSUBSCRIBE commands, but only later realized there's no way to actually route messages to the sub.channels or sub.sharded_channels dictionary on a given channel name.

slact avatar May 18 '22 18:05 slact

As I understand, there is no difference between the MESSAGEs sent to subscribers from PUBLISH or SPUBLISH commands.

Ah, you are right! That's an interesting twist..

bjosv avatar May 23 '22 07:05 bjosv

There are ongoing discussions regarding this problem in https://github.com/redis/redis/issues/10748

bjosv avatar May 23 '22 08:05 bjosv

Oh boy. Well, in the meantime, the official C library does not support the official API.

slact avatar May 24 '22 02:05 slact