Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
d6c61d71
Commit
d6c61d71
authored
Dec 20, 2022
by
Vitaly Arbuzov
Browse files
Resize dict in debug populate command
parent
cbdedf86
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/db.c
View file @
d6c61d71
...
...
@@ -1775,6 +1775,20 @@ int expireIfNeeded(redisDb *db, robj *key, int flags) {
return
1
;
}
/* Increases size of the main db to match desired number. In cluster mode resizes all individual dictionaries for slots that
* this node owns. */
void
expandDb
(
const
redisDb
*
db
,
uint64_t
db_size
)
{
if
(
server
.
cluster_enabled
)
{
clusterNode
*
myself
=
server
.
cluster
->
myself
;
for
(
int
i
=
0
;
i
<
db
->
dict_count
;
i
++
)
{
/* We don't exact number of keys that would fall into each slot, but we can approximate it, assuming even distribution. */
if
(
clusterNodeGetSlotBit
(
myself
,
i
))
dictExpand
(
db
->
dict
[
i
],
(
db_size
/
myself
->
numslots
));
}
}
else
{
dictExpand
(
db
->
dict
[
0
],
db_size
);
}
}
/* -----------------------------------------------------------------------------
* API to get key arguments from commands
* ---------------------------------------------------------------------------*/
...
...
src/debug.c
View file @
d6c61d71
...
...
@@ -716,7 +716,7 @@ NULL
if
(
getPositiveLongFromObjectOrReply
(
c
,
c
->
argv
[
2
],
&
keys
,
NULL
)
!=
C_OK
)
return
;
//
dictE
xpand(c->db
->dict,keys); FIXME (vitarb) find right dicts to expand https://sim.amazon.com/issues/ELMO-63796
e
xpand
Db
(
c
->
db
,
keys
);
long
valsize
=
0
;
if
(
c
->
argc
==
5
&&
getPositiveLongFromObjectOrReply
(
c
,
c
->
argv
[
4
],
&
valsize
,
NULL
)
!=
C_OK
)
return
;
...
...
src/rdb.c
View file @
d6c61d71
...
...
@@ -63,6 +63,9 @@ void rdbCheckSetError(const char *fmt, ...);
#ifdef __GNUC__
void
rdbReportError
(
int
corruption_error
,
int
linenum
,
char
*
reason
,
...)
__attribute__
((
format
(
printf
,
3
,
4
)));
void
expandDb
(
const
redisDb
*
db
,
uint64_t
db_size
);
#endif
void
rdbReportError
(
int
corruption_error
,
int
linenum
,
char
*
reason
,
...)
{
va_list
ap
;
...
...
@@ -3066,15 +3069,7 @@ int rdbLoadRioWithLoadingCtx(rio *rdb, int rdbflags, rdbSaveInfo *rsi, rdbLoadin
goto
eoferr
;
if
((
expires_size
=
rdbLoadLen
(
rdb
,
NULL
))
==
RDB_LENERR
)
goto
eoferr
;
if
(
server
.
cluster_enabled
)
{
clusterNode
*
myself
=
server
.
cluster
->
myself
;
for
(
int
i
=
0
;
i
<
db
->
dict_count
;
i
++
)
{
/* We don't exact number of keys that would fall into each slot, but we can approximate it, assuming even distribution. */
if
(
clusterNodeGetSlotBit
(
myself
,
i
))
dictExpand
(
db
->
dict
[
i
],
(
db_size
/
myself
->
numslots
));
}
}
else
{
dictExpand
(
db
->
dict
[
0
],
db_size
);
}
expandDb
(
db
,
db_size
);
dictExpand
(
db
->
expires
,
expires_size
);
continue
;
/* Read next opcode. */
}
else
if
(
type
==
RDB_OPCODE_AUX
)
{
...
...
src/server.h
View file @
d6c61d71
...
...
@@ -3007,6 +3007,7 @@ unsigned long long int dbSize(const redisDb *db);
dict
*
getDict
(
redisDb
*
db
,
sds
key
);
dict
*
getRandomDict
(
redisDb
*
db
,
int
shouldBeRehashing
);
unsigned
long
dbSlots
(
const
redisDb
*
db
);
void
expandDb
(
const
redisDb
*
db
,
uint64_t
db_size
);
/* Set data type */
robj
*
setTypeCreate
(
sds
value
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment