Hello, I'm testing client side caching with this kind of command:

cnx.execute_command("CLIENT", "TRACKING", "on", "REDIRECT", client_id, "BCAST", "NOLOOP")

And sometime when a client disconnect, the server crash. This is not urgent, it's just to let you know.

redis.txt

Comment From: hwware

Hello @sebastien-petitdemange , thank you for reporting this, can you basically describe what you did in order to help for recreating this crash in my side? Thanks

Comment From: sebastien-petitdemange

Hi @hwware, Yes sure...

This was a really simple test. Several clients use the client caching with the old redis protocol. So one socket to get/set key values and an other socket (pubsub) to receive invalidate messages.

So all clients running Python with gevent and pyredis library. And I notice sometimes when one client exit, It stopped receiving the invalidate messages on one or several clients. If I repeat several time the test ie: connection/de-connection, the server finally crash.

If you want I can extract a minimum code snippet to reproduce the problem, just tell me.

Thanks.

Comment From: hwware

Hello @sebastien-petitdemange , can you send me the simple script that you got this crash if possible, I will try to reproduce in my side, thanks!

Comment From: antirez

This is surely a real bug. Investigating. Thanks.

Comment From: antirez

@sebastien-petitdemange please could you retest with this fix in place?

diff --git a/src/tracking.c b/src/tracking.c
index eb4113131..8c2dca7ba 100644
--- a/src/tracking.c
+++ b/src/tracking.c
@@ -102,7 +102,7 @@ void disableTracking(client *c) {
 /* Set the client 'c' to track the prefix 'prefix'. If the client 'c' is
  * already registered for the specified prefix, no operation is performed. */
 void enableBcastTrackingForPrefix(client *c, char *prefix, size_t plen) {
-    bcastState *bs = raxFind(PrefixTable,(unsigned char*)prefix,sdslen(prefix));
+    bcastState *bs = raxFind(PrefixTable,(unsigned char*)prefix,plen);
     /* If this is the first client subscribing to such prefix, create
      * the prefix in the table. */
     if (bs == raxNotFound) {

Comment From: sebastien-petitdemange

@antirez So fast :wink:. So I applied your patch, and I can't anymore reproduce the problem. Thanks