From 4cd25093a4faee17c26d97c1dc6a0f6e16e6bb44 Mon Sep 17 00:00:00 2001 From: John Sully Date: Wed, 22 Sep 2021 19:24:39 +0000 Subject: [PATCH 1/3] We can't do a command async if there are monitors because we need the lock Former-commit-id: c5b6ade51251a3f57b69d1f3d9c22b199ec00a69 --- src/networking.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/networking.cpp b/src/networking.cpp index 7a28697d3..b25eeaf71 100644 --- a/src/networking.cpp +++ b/src/networking.cpp @@ -2712,7 +2712,7 @@ void readQueryFromClient(connection *conn) { if (cserver.cthreads > 1) { parseClientCommandBuffer(c); - if (g_pserver->enable_async_commands && (aeLockContention() || g_fTestMode)) + if (g_pserver->enable_async_commands && listLength(g_pserver->monitors) == 0 && (aeLockContention() || g_fTestMode)) processInputBuffer(c, false, CMD_CALL_SLOWLOG | CMD_CALL_STATS | CMD_CALL_ASYNC); if (!c->vecqueuedcmd.empty()) serverTL->vecclientsProcess.push_back(c); From 978c578433f9874084925381e785037dd093fe99 Mon Sep 17 00:00:00 2001 From: John Sully Date: Wed, 22 Sep 2021 19:25:57 +0000 Subject: [PATCH 2/3] We returned too early and didn't set the mvcc Former-commit-id: d8e2ffe538a6b237529c37cb142a7076dd4836f8 --- src/object.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/object.cpp b/src/object.cpp index ee6310c41..01b83b4c9 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -1601,23 +1601,22 @@ robj *deserializeStoredStringObject(const char *data, size_t cb) newObject = createObject(OBJ_STRING, nullptr); newObject->encoding = oT->encoding; newObject->m_ptr = oT->m_ptr; - return newObject; + break; case OBJ_ENCODING_EMBSTR: newObject = createEmbeddedStringObject(szFromObj(oT), sdslen(szFromObj(oT))); - return newObject; + break; case OBJ_ENCODING_RAW: newObject = createObject(OBJ_STRING, sdsnewlen(SDS_NOINIT,cb-sizeof(robj)-sizeof(uint64_t))); newObject->lru = oT->lru; memcpy(newObject->m_ptr, data+sizeof(robj)+sizeof(mvcc), cb-sizeof(robj)-sizeof(mvcc)); - return newObject; + break; default: serverPanic("Unknown string object encoding from storage"); } setMvccTstamp(newObject, mvcc); - newObject->setrefcount(1); return newObject; } From e155bbc8736dc684f4f6b8a5f74b5125e3f3c7f6 Mon Sep 17 00:00:00 2001 From: John Sully Date: Wed, 22 Sep 2021 19:26:30 +0000 Subject: [PATCH 3/3] We can't evict in an async command Former-commit-id: 39c2903cbca08c2dbfc3275f83d65e6360c61651 --- src/server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server.cpp b/src/server.cpp index 30a030052..eb50c18f5 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -4777,7 +4777,7 @@ int processCommand(client *c, int callFlags) { * the event loop since there is a busy Lua script running in timeout * condition, to avoid mixing the propagation of scripts with the * propagation of DELs due to eviction. */ - if (g_pserver->maxmemory && !g_pserver->lua_timedout) { + if (g_pserver->maxmemory && !g_pserver->lua_timedout && !(callFlags & CMD_CALL_ASYNC)) { int out_of_memory = (performEvictions(false /*fPreSnapshot*/) == EVICT_FAIL); /* freeMemoryIfNeeded may flush replica output buffers. This may result * into a replica, that may be the active client, to be freed. */