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
ccef4cfa
Commit
ccef4cfa
authored
Apr 05, 2023
by
Vitaly Arbuzov
Browse files
Use calculateKeySlot instead of getKeySlot in defrag
parent
8a5cf63c
Changes
2
Show whitespace changes
Inline
Side-by-side
src/defrag.c
View file @
ccef4cfa
...
@@ -679,12 +679,12 @@ void defragKey(redisDb *db, dictEntry *de) {
...
@@ -679,12 +679,12 @@ void defragKey(redisDb *db, dictEntry *de) {
/* Try to defrag the key name. */
/* Try to defrag the key name. */
newsds
=
activeDefragSds
(
keysds
);
newsds
=
activeDefragSds
(
keysds
);
if
(
newsds
)
{
if
(
newsds
)
{
dictSetKey
(
db
->
dict
[
get
KeySlot
(
newsds
)],
de
,
newsds
);
dictSetKey
(
db
->
dict
[
calculate
KeySlot
(
newsds
)],
de
,
newsds
);
if
(
dictSize
(
db
->
expires
))
{
if
(
dictSize
(
db
->
expires
))
{
/* We can't search in db->expires for that key after we've released
/* We can't search in db->expires for that key after we've released
* the pointer it holds, since it won't be able to do the string
* the pointer it holds, since it won't be able to do the string
* compare, but we can find the entry using key hash and pointer. */
* compare, but we can find the entry using key hash and pointer. */
uint64_t
hash
=
dictGetHash
(
db
->
dict
[
get
KeySlot
(
newsds
)],
newsds
);
uint64_t
hash
=
dictGetHash
(
db
->
dict
[
calculate
KeySlot
(
newsds
)],
newsds
);
dictEntry
*
expire_de
=
dictFindEntryByPtrAndHash
(
db
->
expires
,
keysds
,
hash
);
dictEntry
*
expire_de
=
dictFindEntryByPtrAndHash
(
db
->
expires
,
keysds
,
hash
);
if
(
expire_de
)
dictSetKey
(
db
->
expires
,
expire_de
,
newsds
);
if
(
expire_de
)
dictSetKey
(
db
->
expires
,
expire_de
,
newsds
);
}
}
...
@@ -693,7 +693,7 @@ void defragKey(redisDb *db, dictEntry *de) {
...
@@ -693,7 +693,7 @@ void defragKey(redisDb *db, dictEntry *de) {
/* Try to defrag robj and / or string value. */
/* Try to defrag robj and / or string value. */
ob
=
dictGetVal
(
de
);
ob
=
dictGetVal
(
de
);
if
((
newob
=
activeDefragStringOb
(
ob
)))
{
if
((
newob
=
activeDefragStringOb
(
ob
)))
{
dictSetVal
(
db
->
dict
[
get
KeySlot
(
newsds
)],
de
,
newob
);
dictSetVal
(
db
->
dict
[
calculate
KeySlot
(
newsds
)],
de
,
newob
);
ob
=
newob
;
ob
=
newob
;
}
}
...
@@ -851,7 +851,7 @@ int defragLaterStep(redisDb *db, long long endtime) {
...
@@ -851,7 +851,7 @@ int defragLaterStep(redisDb *db, long long endtime) {
}
}
/* each time we enter this function we need to fetch the key from the dict again (if it still exists) */
/* each time we enter this function we need to fetch the key from the dict again (if it still exists) */
dictEntry
*
de
=
dictFind
(
db
->
dict
[
get
KeySlot
(
defrag_later_current_key
)],
defrag_later_current_key
);
dictEntry
*
de
=
dictFind
(
db
->
dict
[
calculate
KeySlot
(
defrag_later_current_key
)],
defrag_later_current_key
);
key_defragged
=
server
.
stat_active_defrag_hits
;
key_defragged
=
server
.
stat_active_defrag_hits
;
do
{
do
{
int
quit
=
0
;
int
quit
=
0
;
...
...
src/rdb.c
View file @
ccef4cfa
...
@@ -1340,8 +1340,8 @@ ssize_t rdbSaveDb(rio *rdb, int dbid, int rdbflags, long *key_counter) {
...
@@ -1340,8 +1340,8 @@ ssize_t rdbSaveDb(rio *rdb, int dbid, int rdbflags, long *key_counter) {
long long expire;
long long expire;
size_t rdb_bytes_before_key = rdb->processed_bytes;
size_t rdb_bytes_before_key = rdb->processed_bytes;
initStaticStringObject(key,
keystr);
initStaticStringObject(key,keystr);
expire = getExpire(db,
&key);
expire = getExpire(db,&key);
if ((res = rdbSaveKeyValuePair(rdb, &key, o, expire, dbid)) < 0) goto werr;
if ((res = rdbSaveKeyValuePair(rdb, &key, o, expire, dbid)) < 0) goto werr;
written += res;
written += res;
...
...
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