kvrocks icon indicating copy to clipboard operation
kvrocks copied to clipboard

fix: the repl thread may join itself when the server is stopped

Open cxljs opened this issue 9 months ago • 3 comments

ref: #2806

Hi @git-hulk , can you review the pr if you have free time?

cxljs avatar Mar 05 '25 07:03 cxljs

@fukua95 sure, thank you.

git-hulk avatar Mar 05 '25 08:03 git-hulk

I'm wondering if it's possible to add a test case for this?

I test it, but I can't reproduce the bug.

In a multi-thread process, every thread have the chance to be interrupted by derive. When the repl thread be interrupted, it will implement the signal handle function, and the handle function will join the repl thread, which cause deadlock.

I20250226 11:50:45.351392 140030983013952 main.cc:50] Signal Terminated (15) received, stopping the server
W20250226 11:50:45.351526 140030983013952 replication.cc:371] Replication thread operation failed: thread #140030983013952 cannot be `join`ed: Resource deadlock avoided
I20250226 11:50:45.351537 140030983013952 replication.cc:373] [replication] Stopped

From the log, we know the xxx3952 is the repl thread ID, and it received the signal -> call Server::Stop() -> wants to join itself (xxx3952).

cxljs avatar Mar 06 '25 08:03 cxljs