merlimat commented on code in PR #4243:
URL: https://github.com/apache/bookkeeper/pull/4243#discussion_r1981780471
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/KeyValueStorageRocksDB.java:
##########
@@ -285,41 +290,57 @@ private RocksDB initializeRocksDBWithBookieConf(String
basePath, String subPath,
@Override
public void close() throws IOException {
- db.close();
- if (cache != null) {
- cache.close();
- }
- if (options != null) {
- options.close();
- }
- optionSync.close();
- optionDontSync.close();
- optionCache.close();
- optionDontCache.close();
- emptyBatch.close();
+ writeLock.lock();
+ try {
+ closed = true;
+ db.close();
+ if (cache != null) {
+ cache.close();
+ }
+ if (options != null) {
+ options.close();
+ }
+ optionSync.close();
+ optionDontSync.close();
+ optionCache.close();
+ optionDontCache.close();
+ emptyBatch.close();
+ } finally {
+ writeLock.unlock();
+ }
}
@Override
public void put(byte[] key, byte[] value) throws IOException {
+ readLock.lock();
Review Comment:
Acquiring the read lock for each put/get operation might be quite expensive,
since the lock has to maintain the state of threads and the order they try to
acquire the lock.
We could use a different approach, like a reference counter on the entire
object. When everyone is done using it, then rocksdb is really closed
--
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]