-
Notifications
You must be signed in to change notification settings - Fork 137
Open
Description
现象:单个大 Key 全量加载到内存,导致 rdb 进程 OOM
复现方式:
- 使用 lua 脚本创建大 Key。List 类型,5w 个元素,占用内存 4GB
- bgsave 生成 RDB 文件
- 使用 bigkey 分析命令
期望的解决方案:当 Key 超过一定大小时,仅存统计信息
为方便理解 issue 和复现问题,我将测试现场和相关脚本放在这里:
在 FindBiggestKeys 的 dec.Parse(func(object model.RedisObject) 代码段内放置 runtime,输出如下:
- 1w 个 key,接近 1GB 大小,runtime.MemStats 的 alloc 为:977 MiB
- 1.5w 个 key,接近 1.5GB 大小,runtime.MemStats 的 alloc 为:2255 MiB
debug 问题现场图片:
生成 bigkey 的 lua 代码:
`
local element_size = 83800
local element_count = 10000
local payload = string.rep('X', element_size)
for i = 1, element_count do
redis.call('RPUSH', 'example:super_big_key', payload)
end
`
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels