Ryan4253 commented on PR #3019:
URL: https://github.com/apache/kvrocks/pull/3019#issuecomment-2956232995

   @git-hulk thanks for pointing this out!
   
   I took a read at the codebase and noticed there is already a race condition 
between the Storage destructor and compaction filters running in the 
background. SubKeyFilter [holds a pointer to 
Storage](https://github.com/apache/kvrocks/blob/14abba47382334cc91b6fac1c9625e6cb87b2051/src/storage/compact_filter.h#L86)
 and it is one of the thread the Storage destructor [tries to 
stop](https://github.com/apache/kvrocks/blob/065d4cfbfea7034d80df770c0c525e4e4abbb702/src/storage/storage.cc#L105),
 meaning it is possible the filters access storage while it is being 
destructed. 
   
   I think it would be safer to have a Close function similar to 
[Server](https://github.com/apache/kvrocks/blob/14abba47382334cc91b6fac1c9625e6cb87b2051/src/server/server.cc#L248)
 that would clean up resources / stop threads. I can make the change alongside 
this but I want to know what you think.
   
   


-- 
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