summaryrefslogtreecommitdiff
path: root/src/lazyfree.c
diff options
context:
space:
mode:
authorWang Yuan <wangyuancode@163.com>2020-12-02 19:56:11 +0800
committerGitHub <noreply@github.com>2020-12-02 13:56:11 +0200
commitb55a827ea2e19bd6cd48f216e8e6caa34299f9b9 (patch)
treed5698bb9421fe70cf76f406989a816ad979a3935 /src/lazyfree.c
parent84e0489562a0f61b95755dc863bfca79c23b6ef0 (diff)
downloadredis-b55a827ea2e19bd6cd48f216e8e6caa34299f9b9.tar.gz
Backup keys to slots map and restore when fail to sync if diskless-load type is swapdb in cluster mode (#8108)
When replica diskless-load type is swapdb in cluster mode, we didn't backup keys to slots map, so we will lose keys to slots map if fail to sync. Now we backup keys to slots map at first, and restore it properly when fail. This commit includes a refactory/cleanup of the backups mechanism (moving it to db.c and re-structuring it a bit). Co-authored-by: Oran Agra <oran@redislabs.com>
Diffstat (limited to 'src/lazyfree.c')
-rw-r--r--src/lazyfree.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/lazyfree.c b/src/lazyfree.c
index 5a78d5a55..641ab4e64 100644
--- a/src/lazyfree.c
+++ b/src/lazyfree.c
@@ -158,16 +158,10 @@ void emptyDbAsync(redisDb *db) {
bioCreateBackgroundJob(BIO_LAZY_FREE,NULL,oldht1,oldht2);
}
-/* Empty the slots-keys map of Redis CLuster by creating a new empty one
- * and scheduling the old for lazy freeing. */
-void slotToKeyFlushAsync(void) {
- rax *old = server.cluster->slots_to_keys;
-
- server.cluster->slots_to_keys = raxNew();
- memset(server.cluster->slots_keys_count,0,
- sizeof(server.cluster->slots_keys_count));
- atomicIncr(lazyfree_objects,old->numele);
- bioCreateBackgroundJob(BIO_LAZY_FREE,NULL,NULL,old);
+/* Release the radix tree mapping Redis Cluster keys to slots asynchronously. */
+void freeSlotsToKeysMapAsync(rax *rt) {
+ atomicIncr(lazyfree_objects,rt->numele);
+ bioCreateBackgroundJob(BIO_LAZY_FREE,NULL,NULL,rt);
}
/* Release objects from the lazyfree thread. It's just decrRefCount()
@@ -180,9 +174,7 @@ void lazyfreeFreeObjectFromBioThread(robj *o) {
/* Release a database from the lazyfree thread. The 'db' pointer is the
* database which was substituted with a fresh one in the main thread
- * when the database was logically deleted. 'sl' is a skiplist used by
- * Redis Cluster in order to take the hash slots -> keys mapping. This
- * may be NULL if Redis Cluster is disabled. */
+ * when the database was logically deleted. */
void lazyfreeFreeDatabaseFromBioThread(dict *ht1, dict *ht2) {
size_t numkeys = dictSize(ht1);
dictRelease(ht1);
@@ -191,7 +183,7 @@ void lazyfreeFreeDatabaseFromBioThread(dict *ht1, dict *ht2) {
atomicIncr(lazyfreed_objects,numkeys);
}
-/* Release the skiplist mapping Redis Cluster keys to slots in the
+/* Release the radix tree mapping Redis Cluster keys to slots in the
* lazyfree thread. */
void lazyfreeFreeSlotsMapFromBioThread(rax *rt) {
size_t len = rt->numele;