mirror of https://mirror.osredm.com/root/redis.git
hnsw_insert() should never fail in practice.
We pass our aborting allocation function to the HNSW lib, the only other reason for it to fail is pthread mutex locking failing but this is also practically impossible AFAIK in modern systems, and if it happens (for kernel reosurces shortage) anyway to abort is the best thing to do: otherwise we would have to return that we could not complete the operation for some reason, which is not uniform with everything Redis does. In Redis under normal conditions writes must succeed if they are semantically correct, or the server crash for OOM.
This commit is contained in:
parent
8dfc501fb8
commit
3e2649f1f1
2
vset.c
2
vset.c
|
@ -192,6 +192,7 @@ int vectorSetInsert(struct vsetObject *o, float *vec, int8_t *qvec, float qrange
|
|||
* the old value. */
|
||||
hnsw_delete_node(o->hnsw, node, NULL);
|
||||
node = hnsw_insert(o->hnsw,vec,qvec,qrange,0,nv,ef);
|
||||
RedisModule_Assert(node != NULL);
|
||||
RedisModule_DictReplace(o->dict,val,node);
|
||||
|
||||
/* If attrib != NULL, the user wants that in case of an update we
|
||||
|
@ -392,6 +393,7 @@ int VADD_CASReply(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
|||
(newnode = hnsw_try_commit_insert(vset->hnsw, ic)) == NULL)
|
||||
{
|
||||
newnode = hnsw_insert(vset->hnsw, vec, NULL, 0, 0, nv, ef);
|
||||
RedisModule_Assert(newnode != NULL);
|
||||
} else {
|
||||
newnode->value = nv;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue