Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix coredump when slot dict do expand after defrag #1737

Open
wants to merge 1 commit into
base: release3.2-redis-4.0.1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions extern/redis-4.0.1/src/defrag.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,18 @@ int defragKey(redisDb *db, dictEntry *de) {
newsds = activeDefragSds(keysds);
if (newsds)
defragged++, de->key = newsds;

/* 对slot对应的dict进行内存碎片整理,并且使用新的key地址替换老的key地址
* 这里没有对hashtag对应的zset数据结构进行内存整理,向zset数据结构中添加key时,对key做了dup处理,key指针是有效的
*/
do {
uint32_t crc;
int hastag;
int slot = slots_num(de->key, &crc, &hastag);
unsigned int hash = dictGetHash(db->hash_slots[slot], de->key);
replaceSateliteDictKeyPtrAndOrDefragDictEntry(db->hash_slots[slot], keysds, newsds, hash, &defragged);
} while (0);

if (dictSize(db->expires)) {
/* Dirty code:
* I can't search in db->expires for that key after i already released
Expand Down