git-hulk opened a new pull request, #2516:
URL: https://github.com/apache/kvrocks/pull/2516

   This closes #2512.
   
   Currently, the replication thread will wait for the worker's exclusive guard 
stop before closing db. But it now stops the worker from running new commands 
after acquiring the worker's exclusive guard, and it might cause deadlock if 
switches at the same time.
   
   The following steps will show how it may happen:
   
   - T0: client A sent `slaveof MASTER_IP0 MASTER_PORT0`, then the replication 
thread was started and waiting for the exclusive guard.
   
   - T1: client B sent `slaveof MASTER_IP1 MASTER_PORT1` and `AddMaster` will 
stop the previous replication thread, which is waiting for the exclusive guard. 
But the exclusive guard is acquired by the current thread.
   
   The workaround is also straightforward, just stop workers from running new 
commands by enabling `is_loading_` to true before acquiring the lock in the 
replication thread.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to