Vanlightly commented on a change in pull request #2868:
URL: https://github.com/apache/bookkeeper/pull/2868#discussion_r740940894



##########
File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/ReadCache.java
##########
@@ -76,18 +82,24 @@ public ReadCache(ByteBufAllocator allocator, long 
maxCacheSize, int maxSegmentSi
             cacheSegments.add(Unpooled.directBuffer(segmentSize, segmentSize));
             cacheIndexes.add(new ConcurrentLongLongPairHashMap(4096, 2 * 
Runtime.getRuntime().availableProcessors()));
         }
+        isStorageShutdown = false;
     }
 
     @Override
     public void close() {
         cacheSegments.forEach(ByteBuf::release);
+        isStorageShutdown = true;
     }
 
-    public void put(long ledgerId, long entryId, ByteBuf entry) {
+    public void put(long ledgerId, long entryId, ByteBuf entry) throws 
IOException {
         int entrySize = entry.readableBytes();
         int alignedSize = align64(entrySize);
 
         lock.readLock().lock();
+        if (isStorageShutdown) {
+            LOG.error("Read cache has shutdown, not allowing put cache 
operation");
+            throw new IOException();

Review comment:
       Actually Netty and its channels is already shutdown by the time ledger 
storage is shutdown, so no responses can be sent. So making these silent no-ops 
makes sense. It also makes more sense to move this check up to 
SingleDirectoryDbLedgerStorage so that it covers all sub-component (caches, 
entry log, indexes).




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