mirror of https://mirror.osredm.com/root/redis.git
Merge 99c807bd43
into ebf19e4c92
This commit is contained in:
commit
ec4430a965
|
@ -498,6 +498,8 @@ void debugCommand(client *c) {
|
||||||
" Output SHA and content of all scripts or of a specific script with its SHA.",
|
" Output SHA and content of all scripts or of a specific script with its SHA.",
|
||||||
"MARK-INTERNAL-CLIENT [UNMARK]",
|
"MARK-INTERNAL-CLIENT [UNMARK]",
|
||||||
" Promote the current connection to an internal connection.",
|
" Promote the current connection to an internal connection.",
|
||||||
|
"SET key value",
|
||||||
|
" Set a key, even if it is in a slot not owned by this node.",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
addExtendedReplyHelp(c, help, clusterDebugCommandExtendedHelp());
|
addExtendedReplyHelp(c, help, clusterDebugCommandExtendedHelp());
|
||||||
|
@ -1097,6 +1099,9 @@ NULL
|
||||||
addReplySubcommandSyntaxError(c);
|
addReplySubcommandSyntaxError(c);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else if (!strcasecmp(c->argv[1]->ptr, "set") && c->argc == 4) {
|
||||||
|
setKey(c,c->db, c->argv[2], c->argv[3], SETKEY_ADD_OR_UPDATE);
|
||||||
|
addReply(c, shared.ok);
|
||||||
} else if(!handleDebugClusterCommand(c)) {
|
} else if(!handleDebugClusterCommand(c)) {
|
||||||
addReplySubcommandSyntaxError(c);
|
addReplySubcommandSyntaxError(c);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -656,6 +656,11 @@ dictEntry *kvstoreIteratorNext(kvstoreIterator *kvs_it) {
|
||||||
return de;
|
return de;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void kvstoreSkipToNextDict(kvstoreIterator *kvs_it) {
|
||||||
|
dict *d = kvstoreIteratorNextDict(kvs_it);
|
||||||
|
if (d) dictInitSafeIterator(&kvs_it->di, d);
|
||||||
|
}
|
||||||
|
|
||||||
/* This method traverses through kvstore dictionaries and triggers a resize.
|
/* This method traverses through kvstore dictionaries and triggers a resize.
|
||||||
* It first tries to shrink if needed, and if it isn't, it tries to expand. */
|
* It first tries to shrink if needed, and if it isn't, it tries to expand. */
|
||||||
void kvstoreTryResizeDicts(kvstore *kvs, int limit) {
|
void kvstoreTryResizeDicts(kvstore *kvs, int limit) {
|
||||||
|
|
|
@ -68,6 +68,7 @@ int kvstoreNumDicts(kvstore *kvs);
|
||||||
kvstoreIterator *kvstoreIteratorInit(kvstore *kvs);
|
kvstoreIterator *kvstoreIteratorInit(kvstore *kvs);
|
||||||
void kvstoreIteratorRelease(kvstoreIterator *kvs_it);
|
void kvstoreIteratorRelease(kvstoreIterator *kvs_it);
|
||||||
dict *kvstoreIteratorNextDict(kvstoreIterator *kvs_it);
|
dict *kvstoreIteratorNextDict(kvstoreIterator *kvs_it);
|
||||||
|
void kvstoreSkipToNextDict(kvstoreIterator *kvs_it);
|
||||||
int kvstoreIteratorGetCurrentDictIndex(kvstoreIterator *kvs_it);
|
int kvstoreIteratorGetCurrentDictIndex(kvstoreIterator *kvs_it);
|
||||||
dictEntry *kvstoreIteratorNext(kvstoreIterator *kvs_it);
|
dictEntry *kvstoreIteratorNext(kvstoreIterator *kvs_it);
|
||||||
|
|
||||||
|
|
14
src/rdb.c
14
src/rdb.c
|
@ -21,6 +21,7 @@
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "intset.h" /* Compact integer set structure */
|
#include "intset.h" /* Compact integer set structure */
|
||||||
#include "bio.h"
|
#include "bio.h"
|
||||||
|
#include "cluster.h"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -1397,9 +1398,22 @@ ssize_t rdbSaveDb(rio *rdb, int dbid, int rdbflags, long *key_counter) {
|
||||||
|
|
||||||
kvs_it = kvstoreIteratorInit(db->keys);
|
kvs_it = kvstoreIteratorInit(db->keys);
|
||||||
int last_slot = -1;
|
int last_slot = -1;
|
||||||
|
clusterNode *myNode = NULL;
|
||||||
|
if (server.cluster_enabled) {
|
||||||
|
myNode = getMyClusterNode();
|
||||||
|
if (NULL == myNode) {
|
||||||
|
goto werr;
|
||||||
|
}
|
||||||
|
}
|
||||||
/* Iterate this DB writing every entry */
|
/* Iterate this DB writing every entry */
|
||||||
while ((de = kvstoreIteratorNext(kvs_it)) != NULL) {
|
while ((de = kvstoreIteratorNext(kvs_it)) != NULL) {
|
||||||
int curr_slot = kvstoreIteratorGetCurrentDictIndex(kvs_it);
|
int curr_slot = kvstoreIteratorGetCurrentDictIndex(kvs_it);
|
||||||
|
if (server.cluster_enabled) {
|
||||||
|
if (getNodeBySlot(curr_slot) != myNode) {
|
||||||
|
kvstoreSkipToNextDict(kvs_it);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
/* Save slot info. */
|
/* Save slot info. */
|
||||||
if (server.cluster_enabled && curr_slot != last_slot) {
|
if (server.cluster_enabled && curr_slot != last_slot) {
|
||||||
if ((res = rdbSaveType(rdb, RDB_OPCODE_SLOT_INFO)) < 0) goto werr;
|
if ((res = rdbSaveType(rdb, RDB_OPCODE_SLOT_INFO)) < 0) goto werr;
|
||||||
|
|
Loading…
Reference in New Issue