Beihao-Zhou opened a new issue, #2489: URL: https://github.com/apache/kvrocks/issues/2489
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/kvrocks/issues) and found no similar issues. ### Motivation In the context of index, the absence of a locking mechanism could lead to issues when multiple threads attempt to modify shared resources simultaneously. [1] Original issue raised from HNSW #2481 [2] Marked TODO https://github.com/apache/kvrocks/blob/3408318934cb68c0c1f2ffa937f19f02346d0672/src/server/redis_connection.cc#L522-L528 We might want to introduce locks to solve the problem. ### Solution ### Solution 1: Mutex (Straight-forward) We can introduce a mutex map within each IndexInfo structure. This mutex map would contain a mutex for each field that requires protection against concurrent access. #### Con - Blocking if multiple connections update the same index ### Solution 2: Queue We can store the `Update` task for each `IndexInfo` field in a queue, and have a background thread to schedule tasks in order asynchronously. I'm not quite sure about how many number of threads would be appropriate, but can discuss further if everyone leans towards this solution. cc @PragmaTwice ### Are you willing to submit a PR? - [X] I'm willing to submit a PR! -- 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]
