From c2d80e8ced20bd24611dcb436e77a1ae1b694ce3 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 26 Mar 2025 23:41:55 +0100 Subject: [PATCH] Clarify that if CAS fails we insert blocking. --- vset.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vset.c b/vset.c index a6544d897a..e18cae9db8 100644 --- a/vset.c +++ b/vset.c @@ -407,6 +407,9 @@ int VADD_CASReply(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { if (ic == NULL || (newnode = hnsw_try_commit_insert(vset->hnsw, ic)) == NULL) { + /* If we are here, the CAS insert failed. We need to insert + * again with full locking for neighbors selection and + * actual insertion. This time we can't fail: */ newnode = hnsw_insert(vset->hnsw, vec, NULL, 0, 0, nv, ef); RedisModule_Assert(newnode != NULL); } else {