Skip to content

Commit

Permalink
revert it in the future
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoy-binbin committed Nov 22, 2023
1 parent 63dd560 commit d8e4be7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ int clusterNodeIsMyself(clusterNode *n);
clusterNode *getMyClusterNode(void);
char *getMyClusterId(void);
int getClusterSize(void);
int getMyClusterSlotCount(void);
int handleDebugClusterCommand(client *c);
int clusterNodePending(clusterNode *node);
int clusterNodeIsMaster(clusterNode *n);
Expand Down
4 changes: 4 additions & 0 deletions src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -5773,6 +5773,10 @@ int getClusterSize(void) {
return dictSize(server.cluster->nodes);
}

int getMyClusterSlotCount(void) {
return server.cluster->myself->numslots;
}

char **getClusterNodesList(size_t *numnodes) {
size_t count = dictSize(server.cluster->nodes);
char **ids = zmalloc((count+1)*CLUSTER_NAMELEN);
Expand Down
3 changes: 1 addition & 2 deletions src/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

#include "server.h"
#include "cluster.h"
#include "cluster_legacy.h"
#include "atomicvar.h"
#include "latency.h"
#include "script.h"
Expand Down Expand Up @@ -2199,7 +2198,7 @@ int dbExpand(const redisDb *db, uint64_t db_size, dbKeyType keyType, int try_exp
if (server.cluster_enabled) {
/* We don't know exact number of keys that would fall into each slot, but we can
* approximate it, assuming even distribution, divide it by the number of slots. */
int slots = server.cluster->myself->numslots;
int slots = getMyClusterSlotCount();
if (slots == 0) return C_OK;
db_size = db_size / slots;

Expand Down

0 comments on commit d8e4be7

Please sign in to comment.