This commit is contained in:
Yehoshua (Josh) Hershberg 2025-07-11 12:43:09 -07:00 committed by GitHub
commit ec4430a965
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 0 deletions

View File

@ -498,6 +498,8 @@ void debugCommand(client *c) {
" Output SHA and content of all scripts or of a specific script with its SHA.",
"MARK-INTERNAL-CLIENT [UNMARK]",
" 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
};
addExtendedReplyHelp(c, help, clusterDebugCommandExtendedHelp());
@ -1097,6 +1099,9 @@ NULL
addReplySubcommandSyntaxError(c);
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)) {
addReplySubcommandSyntaxError(c);
return;

View File

@ -656,6 +656,11 @@ dictEntry *kvstoreIteratorNext(kvstoreIterator *kvs_it) {
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.
* It first tries to shrink if needed, and if it isn't, it tries to expand. */
void kvstoreTryResizeDicts(kvstore *kvs, int limit) {

View File

@ -68,6 +68,7 @@ int kvstoreNumDicts(kvstore *kvs);
kvstoreIterator *kvstoreIteratorInit(kvstore *kvs);
void kvstoreIteratorRelease(kvstoreIterator *kvs_it);
dict *kvstoreIteratorNextDict(kvstoreIterator *kvs_it);
void kvstoreSkipToNextDict(kvstoreIterator *kvs_it);
int kvstoreIteratorGetCurrentDictIndex(kvstoreIterator *kvs_it);
dictEntry *kvstoreIteratorNext(kvstoreIterator *kvs_it);

View File

@ -21,6 +21,7 @@
#include "functions.h"
#include "intset.h" /* Compact integer set structure */
#include "bio.h"
#include "cluster.h"
#include <math.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);
int last_slot = -1;
clusterNode *myNode = NULL;
if (server.cluster_enabled) {
myNode = getMyClusterNode();
if (NULL == myNode) {
goto werr;
}
}
/* Iterate this DB writing every entry */
while ((de = kvstoreIteratorNext(kvs_it)) != NULL) {
int curr_slot = kvstoreIteratorGetCurrentDictIndex(kvs_it);
if (server.cluster_enabled) {
if (getNodeBySlot(curr_slot) != myNode) {
kvstoreSkipToNextDict(kvs_it);
continue;
}
}
/* Save slot info. */
if (server.cluster_enabled && curr_slot != last_slot) {
if ((res = rdbSaveType(rdb, RDB_OPCODE_SLOT_INFO)) < 0) goto werr;