diff --git a/src/db.c b/src/db.c index e96a43c52..04d94184f 100644 --- a/src/db.c +++ b/src/db.c @@ -687,7 +687,7 @@ static void dbSetValue(redisDb *db, robj *key, robj **valref, dictEntryLink link } } - if (server.io_threads_num > 1 && old->encoding == OBJ_ENCODING_RAW) { + if (server.io_threads_num > 1 && old->encoding == OBJ_ENCODING_RAW && old->refcount == 1) { /* In multi-threaded mode, the OBJ_ENCODING_RAW string object usually is * allocated in the IO thread, so we defer the free to the IO thread. * Besides, we never free a string object in BIO threads, so, even with