Skip to content

Commit

Permalink
Fix for when active rehashing kvstore dictionaries are replaced by de…
Browse files Browse the repository at this point in the history
…frag (#1512)

The kvstore operates the active rehashing by traversing a list of
dictionaries which were registered to it when they started rehashing.
The problem is that active defrag may realloc some of the dictionary
structures while they are registered on the list.where the dictionary 
might be relocated in dictDefragTables.

The Solution is to make sure we update the rehashing list node withy the
new(or not) dictionary pointer after applying the defrag function.

Signed-off-by: Ran Shidlansik <[email protected]>
  • Loading branch information
ranshid authored Jan 6, 2025
1 parent 4fbab57 commit f1a02b4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/kvstore.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,13 @@ void kvstoreDictLUTDefrag(kvstore *kvs, kvstoreDictLUTDefragFunction *defragfn)
for (int didx = 0; didx < kvs->num_dicts; didx++) {
dict **d = kvstoreGetDictRef(kvs, didx), *newd;
if (!*d) continue;
/* In case we will defrag the dictionary while it is registered to active-rehashing
* we need to make sure to update the registration in the rehashing list.
* So we keep the list node and after the defrag operation completes we reassign the value to the
* dictionary pointer. */
listNode *rehashing_node = ((kvstoreDictMetadata *)dictMetadata(*d))->rehashing_node;
if ((newd = defragfn(*d))) *d = newd;
if (rehashing_node) listNodeValue(rehashing_node) = *d;
}
}

Expand Down

0 comments on commit f1a02b4

Please sign in to comment.