apache / kvrocks

Apache Kvrocks is a distributed key value NoSQL database that uses RocksDB as storage engine and is compatible with Redis protocol.
https://kvrocks.apache.org/
Apache License 2.0
3.53k stars 464 forks source link

Dead lock possible? #257

Closed calvinxiao closed 3 years ago

calvinxiao commented 3 years ago

The following code loop over vector<StringPair> and perform locking on each item.

If the keys are not sorted, is there going to be a potential dead lock problem?

git-hulk commented 3 years ago

Good question, there's not a possible deadlock since we lock and unlock one key every loop. if we lock all keys outside at once outside the loop that may cause deadlock without sorting.

calvinxiao commented 3 years ago

Right, it will get unlocked after each loop.