Snapchat / KeyDB

A Multithreaded Fork of Redis
https://keydb.dev
BSD 3-Clause "New" or "Revised" License
11.54k stars 579 forks source link

[BUG] Crash when exiting from MONITOR #777

Open keithchew opened 10 months ago

keithchew commented 10 months ago

Testing on v6.3.4, steps below for crash (not all the time, but quite reproducible):

- MONITOR
- Ctrl-C to break out

Stack trace:

=== KEYDB BUG REPORT START: Cut & paste starting from here ===
7:68:M 22 Jan 2024 00:47:01.865 # === ASSERTION FAILED ===
7:68:M 22 Jan 2024 00:47:01.865 # ==> networking.cpp:1591 'fFound' is not true

------ STACK TRACE ------

Backtrace:
/opt/KeyDB/bin/keydb-server *:6379(unlinkClient(client*)+0x6b1) [0x55f046fc58d1]
/opt/KeyDB/bin/keydb-server *:6379(freeClient(client*)+0x3cd) [0x55f046fc5dbd]
/opt/KeyDB/bin/keydb-server *:6379(freeClientsInAsyncFreeQueue(int)+0xff) [0x55f046fc6faf]
/opt/KeyDB/bin/keydb-server *:6379(beforeSleep(aeEventLoop*)+0x4cc) [0x55f046fa776c]
/opt/KeyDB/bin/keydb-server *:6379(aeProcessEvents+0x400) [0x55f046f98f70]
/opt/KeyDB/bin/keydb-server *:6379(aeMain+0x3e) [0x55f046f9975e]
/opt/KeyDB/bin/keydb-server *:6379(workerThreadMain(void*)+0x12b) [0x55f046fb264b]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x8609) [0x7f5e689a5609]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x43) [0x7f5e688ca353]

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

I haven't traced into the cause yet, but wanted to report this first just in case the bug has already been identified/fixed.

keithchew commented 4 months ago

Just an update. I can confirm the crash always happens, so it must be a bug when the command is MONITOR, perhaps it is a streaming command as opposed to others which are not. Commenting out the assert line prevents the crash, but a better solution is to probably fix it properly. I found that occasionally the the stream does not capture all the traffic. so perhaps there is more to this issue than just a crash.