tair-opensource / RedisShake

RedisShake is a Redis data processing and migration tool.
https://tair-opensource.github.io/RedisShake/
MIT License
3.85k stars 698 forks source link

sync aws elasticache to huawei cloud receive fatal error: runtime: out of memory #731

Closed younghawk closed 11 months ago

younghawk commented 11 months ago

问题描述(Issue Description)

sync aws elasticache to huawei cloud receive fatal error: runtime: out of memory

请在这里简要描述你遇到的问题。 每次在同步rdb 到1G 后,就报out of memory, 这是redis_shake 的out of memory ,安装 redis_shake 服务器 16G,我查看内存剩余5G, : Please provide a brief description of the issue you encountered.

环境信息(Environment)

日志信息(Logs)

如果有错误日志或其他相关日志,请在这里提供。

ueueEntriesCount=[1023], unansweredBytesCount=[0]bytes, rdbFileSize=[5.461]G, rdbSendSize=[0.981]G 2023-12-17 23:09:53 INF syncing rdb. percent=[18.73]%, allowOps=[84235.40], disallowOps=[0.00], entryId=[10251983], InQueueEntriesCount=[1022], unansweredBytesCount=[5401]bytes, rdbFileSize=[5.461]G, rdbSendSize=[1.023]G 2023-12-17 23:09:58 INF syncing rdb. percent=[19.35]%, allowOps=[61712.80], disallowOps=[0.00], entryId=[10560555], InQueueEntriesCount=[0], unansweredBytesCount=[0]bytes, rdbFileSize=[5.461]G, rdbSendSize=[1.057]G 2023-12-17 23:10:03 INF syncing rdb. percent=[19.35]%, allowOps=[0.00], disallowOps=[0.00], entryId=[10560555], InQueueEntriesCount=[0], unansweredBytesCount=[0]bytes, rdbFileSize=[5.461]G, rdbSendSize=[1.057]G 2023-12-17 23:10:08 INF syncing rdb. percent=[19.35]%, allowOps=[0.00], disallowOps=[0.00], entryId=[10560555], InQueueEntriesCount=[0], unansweredBytesCount=[0]bytes, rdbFileSize=[5.461]G, rdbSendSize=[1.057]G 2023-12-17 23:10:13 INF syncing rdb. percent=[19.35]%, allowOps=[0.00], disallowOps=[0.00], entryId=[10560555], InQueueEntriesCount=[0], unansweredBytesCount=[0]bytes, rdbFileSize=[5.461]G, rdbSendSize=[1.057]G 2023-12-17 23:10:18 INF syncing rdb. percent=[19.35]%, allowOps=[0.00], disallowOps=[0.00], entryId=[10560555], InQueueEntriesCount=[0], unansweredBytesCount=[0]bytes, rdbFileSize=[5.461]G, rdbSendSize=[1.057]G 2023-12-17 23:10:23 INF syncing rdb. percent=[19.35]%, allowOps=[0.00], disallowOps=[0.00], entryId=[10560555], InQueueEntriesCount=[0], unansweredBytesCount=[0]bytes, rdbFileSize=[5.461]G, rdbSendSize=[1.057]G fatal error: runtime: out of memory

runtime stack: runtime.throw({0x7a29f0, 0x100400000}) runtime/panic.go:1198 +0x71 runtime.sysMap(0xc2c0000000, 0x4294c0, 0xc000045e90) runtime/mem_linux.go:169 +0x96 runtime.(mheap).grow(0xa63860, 0x80003) runtime/mheap.go:1393 +0x225 runtime.(mheap).allocSpan(0xa63860, 0x80003, 0x0, 0x1) runtime/mheap.go:1179 +0x165 runtime.(*mheap).alloc.func1() runtime/mheap.go:913 +0x69 runtime.systemstack() runtime/asm_amd64.s:383 +0x49

goroutine 18 [running]: runtime.systemstack_switch() runtime/asm_amd64.s:350 fp=0xc0000d1680 sp=0xc0000d1678 pc=0x465980 runtime.(mheap).alloc(0x100006000, 0x80003, 0x2, 0x0) runtime/mheap.go:907 +0x73 fp=0xc0000d16d0 sp=0xc0000d1680 pc=0x425813 runtime.(mcache).allocLarge(0x4a16ed, 0x100005e9a, 0x9, 0x1) runtime/mcache.go:227 +0x89 fp=0xc0000d1730 sp=0xc0000d16d0 pc=0x4164c9 runtime.mallocgc(0x100005e9a, 0x73a600, 0x1) runtime/malloc.go:1088 +0x5c5 fp=0xc0000d17b0 sp=0xc0000d1730 pc=0x40ca45 runtime.makeslice(0x0, 0x0, 0x4b7bc0) runtime/slice.go:98 +0x52 fp=0xc0000d17d8 sp=0xc0000d17b0 pc=0x44c012 bytes.makeSlice(0x100005e9a) bytes/buffer.go:229 +0x65 fp=0xc0000d1828 sp=0xc0000d17d8 pc=0x4d8145 bytes.(Buffer).grow(0xc0002ac960, 0xbe2) bytes/buffer.go:142 +0x11f fp=0xc0000d1870 sp=0xc0000d1828 pc=0x4d7b7f bytes.(Buffer).Write(0xc0002ac960, {0xc0d9f09813, 0xbe2, 0x0}) bytes/buffer.go:172 +0x66 fp=0xc0000d18a0 sp=0xc0000d1870 pc=0x4d7d66 io.(teeReader).Read(0xc000020e80, {0xc0d9f09813, 0xc0000d1920, 0xbe2}) io/io.go:562 +0x77 fp=0xc0000d18e8 sp=0xc0000d18a0 pc=0x4997d7 io.ReadAtLeast({0x816aa0, 0xc000020e80}, {0xc0d9f09300, 0x10f5, 0x10f5}, 0x10f5) io/io.go:328 +0x9a fp=0xc0000d1930 sp=0xc0000d18e8 pc=0x49907a io.ReadFull(...) io/io.go:347 github.com/alibaba/RedisShake/internal/rdb/structure.ReadBytes({0x816aa0, 0xc000020e80}, 0x666cb5) github.com/alibaba/RedisShake/internal/rdb/structure/byte.go:15 +0x55 fp=0xc0000d1980 sp=0xc0000d1930 pc=0x666cb5 github.com/alibaba/RedisShake/internal/rdb/structure.ReadString({0x816aa0, 0xc000020e80}) github.com/alibaba/RedisShake/internal/rdb/structure/string.go:35 +0x157 fp=0xc0000d19e8 sp=0xc0000d1980 pc=0x668517 github.com/alibaba/RedisShake/internal/rdb/structure.ReadZipList({0x816aa0, 0xc000020e80}) github.com/alibaba/RedisShake/internal/rdb/structure/ziplist.go:27 +0x3e fp=0xc0000d1b20 sp=0xc0000d19e8 pc=0x66885e github.com/alibaba/RedisShake/internal/rdb/types.(ListObject).readQuickList(0xc0002ac990, {0x816aa0, 0xc000020e80}) github.com/alibaba/RedisShake/internal/rdb/types/list.go:57 +0x6c fp=0xc0000d1b90 sp=0xc0000d1b20 pc=0x66a10c github.com/alibaba/RedisShake/internal/rdb/types.(ListObject).LoadFromBuffer(0x0, {0x816aa0, 0xc000020e80}, {0xc000451f30, 0x20}, 0x68) github.com/alibaba/RedisShake/internal/rdb/types/list.go:29 +0xf8 fp=0xc0000d1bd8 sp=0xc0000d1b90 pc=0x669d58 github.com/alibaba/RedisShake/internal/rdb/types.ParseObject({0x816aa0, 0xc000020e80}, 0xe, {0xc000451f30, 0x40}) github.com/alibaba/RedisShake/internal/rdb/types/interface.go:75 +0x2ec fp=0xc0000d1c68 sp=0xc0000d1bd8 pc=0x669b4c github.com/alibaba/RedisShake/internal/rdb.(Loader).parseRDBEntry(0xc000164000, 0xc000282240) github.com/alibaba/RedisShake/internal/rdb/rdb.go:156 +0x7a6 fp=0xc0000d1e00 sp=0xc0000d1c68 pc=0x6cfb06 github.com/alibaba/RedisShake/internal/rdb.(Loader).ParseRDB(0xc000164000) github.com/alibaba/RedisShake/internal/rdb/rdb.go:85 +0x3f7 fp=0xc0000d1f38 sp=0xc0000d1e00 pc=0x6cf157 github.com/alibaba/RedisShake/internal/reader.(psyncReader).sendRDB(0xc0002aa000) github.com/alibaba/RedisShake/internal/reader/psync.go:214 +0xbd fp=0xc0000d1fa8 sp=0xc0000d1f38 pc=0x6d23dd github.com/alibaba/RedisShake/internal/reader.(psyncReader).StartRead.func1() github.com/alibaba/RedisShake/internal/reader/psync.go:49 +0xf9 fp=0xc0000d1fe0 sp=0xc0000d1fa8 pc=0x6d1299 runtime.goexit() runtime/asm_amd64.s:1581 +0x1 fp=0xc0000d1fe8 sp=0xc0000d1fe0 pc=0x467a61 created by github.com/alibaba/RedisShake/internal/reader.(psyncReader).StartRead github.com/alibaba/RedisShake/internal/reader/psync.go:43 +0x8f

goroutine 1 [chan receive]: main.main() github.com/alibaba/RedisShake/cmd/redis-shake/main.go:97 +0x613

goroutine 33 [chan receive]: github.com/alibaba/RedisShake/internal/writer.(*redisWriter).flushInterval(0xc000197500) github.com/alibaba/RedisShake/internal/writer/redis.go:68 +0x54 created by github.com/alibaba/RedisShake/internal/writer.NewRedisWriter github.com/alibaba/RedisShake/internal/writer/redis.go:36 +0x19c

goroutine 19 [chan receive]: github.com/alibaba/RedisShake/internal/statistics.Init.func1() github.com/alibaba/RedisShake/internal/statistics/statistics.go:65 +0xfa created by github.com/alibaba/RedisShake/internal/statistics.Init github.com/alibaba/RedisShake/internal/statistics/statistics.go:56 +0x25

goroutine 20 [chan receive]: github.com/alibaba/RedisShake/internal/reader.(psyncReader).sendReplconfAck(0xc0002aa000) github.com/alibaba/RedisShake/internal/reader/psync.go:243 +0xe5 created by github.com/alibaba/RedisShake/internal/reader.(psyncReader).StartRead.func1 github.com/alibaba/RedisShake/internal/reader/psync.go:45 +0x68

goroutine 23 [IO wait]: internal/poll.runtime_pollWait(0x7f80590072a8, 0x72) runtime/netpoll.go:303 +0x85 internal/poll.(pollDesc).wait(0xc0002ce280, 0xc00022a000, 0x0) internal/poll/fd_poll_runtime.go:84 +0x32 internal/poll.(pollDesc).waitRead(...) internal/poll/fd_poll_runtime.go:89 internal/poll.(FD).Read(0xc0002ce280, {0xc00022a000, 0x4000, 0x4000}) internal/poll/fd_unix.go:167 +0x25a net.(netFD).Read(0xc0002ce280, {0xc00022a000, 0x4b6540, 0xc0000a6000}) net/fd_posix.go:56 +0x29 net.(conn).Read(0xc0000ac010, {0xc00022a000, 0xf5, 0xc0000d3f08}) net/net.go:183 +0x45 bufio.(Reader).Read(0xc0000a60c0, {0xc00022a000, 0x4000, 0x4000}) bufio/bufio.go:213 +0x106 github.com/alibaba/RedisShake/internal/reader.(psyncReader).saveAOF(0xc0002aa000, {0x8165a0, 0xc0000a60c0}) github.com/alibaba/RedisShake/internal/reader/psync.go:200 +0x151 created by github.com/alibaba/RedisShake/internal/reader.(psyncReader).StartRead.func1 github.com/alibaba/RedisShake/internal/reader/psync.go:48 +0xef

其他信息(Additional Information)

请提供任何其他相关的信息,如配置文件、错误信息或截图等。

Please provide any additional information, such as configuration files, error messages, or screenshots.

younghawk commented 11 months ago

问题已经解决,我把执行redis_shark 的机器升级到64G ,发现在迁移过程中物理内存rss 占用高达 28G

suxb201 commented 11 months ago

在处理 rdb 时确实还有内存的膨胀,请问源端 rdb 的大小是多少?怀疑实例中存在大 key