redis icon indicating copy to clipboard operation
redis copied to clipboard

Redis 3.2.3 Crash when appendonly=yes

Open yuyi opened this issue 10 years ago • 10 comments

Redis 3.2.3 crash when I run "redis-cli config set appendonly=yes". There are so many LISTs in redisdb. ( Length of a list is more than 100k. )

15615:C 05 Aug 03:11:23.189 # === ASSERTION FAILED === 15615:C 05 Aug 03:11:23.189 # ==> ziplist.c:411 'NULL' is not true 15615:C 05 Aug 03:11:23.189 # (forcing SIGSEGV to print the bug report.) 15615:C 05 Aug 03:11:23.189 # Redis 3.2.3 crashed by signal: 11 15615:C 05 Aug 03:11:23.189 # Crashed running the instuction at: 0x45ca1a 15615:C 05 Aug 03:11:23.189 # Accessing address: 0xffffffffffffffff 15615:C 05 Aug 03:11:23.189 # Failed assertion: NULL (ziplist.c:411)

------ STACK TRACE ------ EIP: redis-aof-rewrite 127.0.0.1:6379(_serverAssert+0x6a)[0x45ca1a]

Backtrace: redis-aof-rewrite 127.0.0.1:6379(logStackTrace+0x29)[0x45e6c9] redis-aof-rewrite 127.0.0.1:6379(sigsegvHandler+0xaa)[0x45ebfa] /lib/x86_64-linux-gnu/libpthread.so.0(+0x10330)[0x7f4cf5475330] redis-aof-rewrite 127.0.0.1:6379(_serverAssert+0x6a)[0x45ca1a] redis-aof-rewrite 127.0.0.1:6379[0x43173f] redis-aof-rewrite 127.0.0.1:6379(ziplistGet+0x57)[0x4323f7] redis-aof-rewrite 127.0.0.1:6379(quicklistNext+0x184)[0x4203c4] redis-aof-rewrite 127.0.0.1:6379(rewriteListObject+0x93)[0x459113] redis-aof-rewrite 127.0.0.1:6379(rewriteAppendOnlyFile+0x4da)[0x459d3a] redis-aof-rewrite 127.0.0.1:6379(rewriteAppendOnlyFileBackground+0x170)[0x45a3c0] redis-aof-rewrite 127.0.0.1:6379(serverCron+0x6a5)[0x427bc5] redis-aof-rewrite 127.0.0.1:6379(aeProcessEvents+0x2b0)[0x4214c0] redis-aof-rewrite 127.0.0.1:6379(aeMain+0x2b)[0x4216db] redis-aof-rewrite 127.0.0.1:6379(main+0x410)[0x41e690] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7f4cf50c1f45] redis-aof-rewrite 127.0.0.1:6379[0x41e902]

------ INFO OUTPUT ------

Server

redis_version:3.2.3 redis_git_sha1:00000000 redis_git_dirty:0 redis_build_id:839c026e586697f4 redis_mode:standalone os:Linux 3.13.0-24-generic x86_64 arch_bits:64 multiplexing_api:epoll gcc_version:4.8.4 process_id:15615 run_id:8d98752264d6777e1de6795502e4dec0706b7a04 tcp_port:6379 uptime_in_seconds:2212 uptime_in_days:0 hz:10 lru_clock:10720086 executable:/usr/local/bin/redis-server config_file:/etc/redis/redis.conf

Clients

connected_clients:2 client_longest_output_list:0 client_biggest_input_buf:0 blocked_clients:0

Memory

used_memory:12186031992 used_memory_human:11.35G used_memory_rss:501387264 used_memory_rss_human:478.16M used_memory_peak:12186504432 used_memory_peak_human:11.35G total_system_memory:16502407168 total_system_memory_human:15.37G used_memory_lua:37888 used_memory_lua_human:37.00K maxmemory:0 maxmemory_human:0B maxmemory_policy:noeviction mem_fragmentation_ratio:0.04 mem_allocator:jemalloc-4.0.3

Persistence

loading:0 rdb_changes_since_last_save:24 rdb_bgsave_in_progress:0 rdb_last_save_time:1470335666 rdb_last_bgsave_status:ok rdb_last_bgsave_time_sec:-1 rdb_current_bgsave_time_sec:-1 aof_enabled:1 aof_rewrite_in_progress:0 aof_rewrite_scheduled:1 aof_last_rewrite_time_sec:152 aof_current_rewrite_time_sec:-1 aof_last_bgrewrite_status:err aof_last_write_status:ok aof_current_size:0 aof_base_size:0 aof_pending_rewrite:1 aof_buffer_length:0 aof_rewrite_buffer_length:0 aof_pending_bio_fsync:0 aof_delayed_fsync:0

Stats

total_connections_received:10 total_commands_processed:1747669 instantaneous_ops_per_sec:1106 total_net_input_bytes:99306200 total_net_output_bytes:1256255958 instantaneous_input_kbps:62.12 instantaneous_output_kbps:629.87 rejected_connections:0 sync_full:0 sync_partial_ok:0 sync_partial_err:0 expired_keys:0 evicted_keys:0 keyspace_hits:880000 keyspace_misses:0 pubsub_channels:0

pubsub_patterns:0 latest_fork_usec:193770 migrate_cached_sockets:0

Replication

role:master connected_slaves:0 master_repl_offset:0 repl_backlog_active:0 repl_backlog_size:1048576 repl_backlog_first_byte_offset:0 repl_backlog_histlen:0

CPU

used_cpu_sys:0.35 used_cpu_user:0.13 used_cpu_sys_children:0.00 used_cpu_user_children:0.00

Commandstats

cmdstat_exists:calls=847000,usec=882516,usec_per_call=1.04 cmdstat_sismember:calls=877250,usec=761776,usec_per_call=0.87 cmdstat_hmset:calls=24,usec=6263,usec_per_call=260.96 cmdstat_hgetall:calls=2750,usec=1503081,usec_per_call=546.57 cmdstat_ping:calls=6,usec=5,usec_per_call=0.83 cmdstat_info:calls=4,usec=260,usec_per_call=65.00 cmdstat_config:calls=2,usec=164818,usec_per_call=82409.00 cmdstat_publish:calls=16500,usec=3011,usec_per_call=0.18 cmdstat_evalsha:calls=4125,usec=49430,usec_per_call=11.98 cmdstat_command:calls=8,usec=108418,usec_per_call=13552.25

Cluster

cluster_enabled:0

Keyspace

db0:keys=16095433,expires=23369,avg_ttl=340415182 db1:keys=11071649,expires=10844022,avg_ttl=615590081922 hash_init_value: 1471059018

------ CLIENT LIST OUTPUT ------ id=2 addr=127.0.0.1:40336 fd=6 name= age=2211 idle=1 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=publish id=3 addr=127.0.0.1:40337 fd=7 name= age=2211 idle=179 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=hmset

------ REGISTERS ------ 15615:C 05 Aug 03:11:23.193 # RAX:0000000000000000 RBX:000000000000019b RCX:00000000fbad000c RDX:0000000000000000 RDI:00007f4cf545e760 RSI:0000000000000000 RBP:00000000004df648 RSP:00007fff29d5c570 R8 :000000000139f030 R9 :00007f4cf5b83780 R10:00007f4cf545d6a0 R11:0000000000000206 R12:00000000004df7f4 R13:00007fff29d5c648 R14:0000000000000040 R15:00007fff29d5c6d0 RIP:000000000045ca1a EFL:0000000000010206 CSGSFS:0000000000000033 15615:C 05 Aug 03:11:23.193 # (00007fff29d5c57f) -> 0000000000000001 15615:C 05 Aug 03:11:23.193 # (00007fff29d5c57e) -> 00007fff29d5c620 15615:C 05 Aug 03:11:23.193 # (00007fff29d5c57d) -> 00007f4aac92ab58 15615:C 05 Aug 03:11:23.193 # (00007fff29d5c57c) -> 0000000000000002 15615:C 05 Aug 03:11:23.193 # (00007fff29d5c57b) -> 00007f4bb24eb87d 15615:C 05 Aug 03:11:23.193 # (00007fff29d5c57a) -> 00007fff00000002 15615:C 05 Aug 03:11:23.193 # (00007fff29d5c579) -> 0000000000000001 15615:C 05 Aug 03:11:23.193 # (00007fff29d5c578) -> 0000000000000001 15615:C 05 Aug 03:11:23.193 # (00007fff29d5c577) -> 00000000004323f7 15615:C 05 Aug 03:11:23.193 # (00007fff29d5c576) -> 0000000000000002 15615:C 05 Aug 03:11:23.193 # (00007fff29d5c575) -> 00007fff29d5c6e0 15615:C 05 Aug 03:11:23.193 # (00007fff29d5c574) -> 0000000000000002 15615:C 05 Aug 03:11:23.193 # (00007fff29d5c573) -> 000000000043173f 15615:C 05 Aug 03:11:23.194 # (00007fff29d5c572) -> 00007fff29d5c640 15615:C 05 Aug 03:11:23.194 # (00007fff29d5c571) -> 00007fff29d5c638 15615:C 05 Aug 03:11:23.194 # (00007fff29d5c570) -> 00007f4bb24eb87d

------ FAST MEMORY TEST ------ *** Preparing to test memory region 724000 (94208 bytes) *** Preparing to test memory region 1392000 (135168 bytes) *** Preparing to test memory region 7f4a09c00000 (12509511680 bytes) *** Preparing to test memory region 7f4cf37ff000 (8388608 bytes) *** Preparing to test memory region 7f4cf4000000 (8388608 bytes) *** Preparing to test memory region 7f4cf4800000 (2097152 bytes) *** Preparing to test memory region 7f4cf4e00000 (2097152 bytes) *** Preparing to test memory region 7f4cf5460000 (20480 bytes) *** Preparing to test memory region 7f4cf567f000 (16384 bytes) *** Preparing to test memory region 7f4cf5b83000 (16384 bytes) *** Preparing to test memory region 7f4cf5ba7000 (8192 bytes) *** Preparing to test memory region 7f4cf5ba9000 (8192 bytes) *** Preparing to test memory region 7f4cf5bad000 (4096 bytes)

yuyi avatar Aug 04 '16 19:08 yuyi

please tell me the config list-max-ziplist-size? the list is more than 100k, is too long! proposed list-max-ziplist-size <16kb

andyli029 avatar Aug 08 '16 09:08 andyli029

list-max-ziplist-size -2

100k is the worst case. The normal length is about 5k. Is redis could not support list more than 100k?

yuyi avatar Aug 08 '16 09:08 yuyi

@Yuyi I think it is lack of physical memory. when you turn on appendonly as yes. redis must fork. and you already use more than 11G. so It is possbile. but your rss size is somewhat weird.

charsyam avatar Aug 08 '16 09:08 charsyam

Hi @charsyam,

This mechine has 47G ram and 32G swap with overcommit = 1. So I think it enough for forking.

RSS Size was very weird... But it's normal now:

Memory

used_memory:14990744080 used_memory_human:13.96G used_memory_rss:15415443456 used_memory_rss_human:14.36G used_memory_peak:14991030280 used_memory_peak_human:13.96G

yuyi avatar Aug 08 '16 11:08 yuyi

@Yuyi That's why I misunderstand. Actually total_system_memory means your phsical total memory size so I think your memory size is 16G.

Did you check your /var/log/messages for OOM? If you find OOM log in it at that time? maybe It might be because of lack of memory :)

charsyam avatar Aug 09 '16 02:08 charsyam

@Yuyi Do you have the coredump file and the binary file ? please give me ,thanks!

andyli029 avatar Aug 09 '16 02:08 andyli029

@andyli029 @charsyam

I found a way to reproduce the bug at redis 3.2.3 x86_64:

step 1. load redis.rdb

xxd redis.rdb 00000000: 5245 4449 5330 3030 37fa 0972 6564 6973 REDIS0007..redis 00000010: 2d76 6572 0533 2e32 2e33 fa0a 7265 6469 -ver.3.2.3..redi 00000020: 732d 6269 7473 c040 fa05 6374 696d 65c2 [email protected]. 00000030: 0b5b c157 fa08 7573 6564 2d6d 656d c250 .[.W..used-mem.P 00000040: 4a08 00fe 00fb 0100 0e07 4558 414d 504c J.........EXAMPL 00000050: 4501 404a 4a00 0000 0a00 0000 0100 003d E.@JJ..........= 00000060: 5b32 3230 3937 3635 2c22 4040 222c 3134 [2209765,"@@",14 00000070: 3638 3936 3932 3231 3336 362c 2200 0000 68969221366,"... 00000080: 0000 0000 8049 a2a2 0100 0000 33ab b25a .....I......3..Z 00000090: 2a7f 0000 1a1a 0161 6374 6976 655f ff1c *......active_.. 000000a0: 75e9 54c4 c9c3 6a u.T...j

(save these lines to file, and use " xxd -r file > redis.rdb" to get redis.rdb)

step 2. redis-cli config set appendonly yes

step 3. watch logs...

yuyi avatar Aug 27 '16 09:08 yuyi

Hello @Yuyi, I'm investigating a set of Redis crashes and reached your issue. I noticed that the content of the EXAMPLE key in your example RDB file is something like:

[2209765,"@@",1468969221366,"

As you can see it looks truncated. Do you remember what could be a potentially valid element format? Was it correctly structured like if the above probably lacks a closing ]? Was it mostly composed of normal printable characters, that is, no binary data?

Because inside the RDB file instead the content after the above string is garbage like in:

[2209765,"@@",1468969221366,"^@^@^@^@^@^@^@<80>I<A2><A2>

And I was trying to understand how the corruption could be caused. Thanks.

antirez avatar Jan 16 '17 11:01 antirez

Hi @antirez, Yes, It should be JSON format with a closing ] and no binary data.

Example: [2209765,"@@",1468969221366,""] Thanks.

yuyi avatar Jan 16 '17 11:01 yuyi

Thanks @Yuyi

antirez avatar Jan 16 '17 11:01 antirez