diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/KeyValueStorageRocksDB.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/KeyValueStorageRocksDB.java index 4433cb13367..a90fc1a6e65 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/KeyValueStorageRocksDB.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/KeyValueStorageRocksDB.java @@ -433,6 +433,7 @@ public void compact(byte[] firstKey, byte[] lastKey) throws IOException { public void compact() throws IOException { readLock.lock(); try { + throwIfClosed(); final long start = System.currentTimeMillis(); final int oriRocksDBFileCount = db.getLiveFilesMetaData().size(); final long oriRocksDBSize = getRocksDBSize(); @@ -646,9 +647,10 @@ public long count() throws IOException { } @Override - public Batch newBatch() { + public Batch newBatch() throws IOException { readLock.lock(); try { + throwIfClosed(); return new RocksDBBatch(writeBatchMaxSize); } finally { readLock.unlock();