Commit d0477098 authored by antirez's avatar antirez
Browse files

Cluster: empty the internal sorted set mapping keys to slots on FLUSHDB/ALL.

parent efe51dff
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
void SlotToKeyAdd(robj *key); void SlotToKeyAdd(robj *key);
void SlotToKeyDel(robj *key); void SlotToKeyDel(robj *key);
void SlotToKeyFlush(void);
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
* C-level DB API * C-level DB API
...@@ -213,12 +214,14 @@ void flushdbCommand(redisClient *c) { ...@@ -213,12 +214,14 @@ void flushdbCommand(redisClient *c) {
signalFlushedDb(c->db->id); signalFlushedDb(c->db->id);
dictEmpty(c->db->dict); dictEmpty(c->db->dict);
dictEmpty(c->db->expires); dictEmpty(c->db->expires);
if (server.cluster_enabled) SlotToKeyFlush();
addReply(c,shared.ok); addReply(c,shared.ok);
} }
void flushallCommand(redisClient *c) { void flushallCommand(redisClient *c) {
signalFlushedDb(-1); signalFlushedDb(-1);
server.dirty += emptyDb(); server.dirty += emptyDb();
if (server.cluster_enabled) SlotToKeyFlush();
addReply(c,shared.ok); addReply(c,shared.ok);
if (server.rdb_child_pid != -1) { if (server.rdb_child_pid != -1) {
kill(server.rdb_child_pid,SIGUSR1); kill(server.rdb_child_pid,SIGUSR1);
...@@ -755,6 +758,11 @@ void SlotToKeyDel(robj *key) { ...@@ -755,6 +758,11 @@ void SlotToKeyDel(robj *key) {
zslDelete(server.cluster->slots_to_keys,hashslot,key); zslDelete(server.cluster->slots_to_keys,hashslot,key);
} }
void SlotToKeyFlush(void) {
zslFree(server.cluster->slots_to_keys);
server.cluster->slots_to_keys = zslCreate();
}
unsigned int GetKeysInSlot(unsigned int hashslot, robj **keys, unsigned int count) { unsigned int GetKeysInSlot(unsigned int hashslot, robj **keys, unsigned int count) {
zskiplistNode *n; zskiplistNode *n;
zrangespec range; zrangespec range;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment