junrao commented on code in PR #23316:
URL: https://github.com/apache/kafka/pull/23316#discussion_r3968603351


##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LocalLog.java:
##########
@@ -659,7 +659,7 @@ public List<LogSegment> truncateFullyAndStartAt(long 
newOffset) {
             () -> "Error while truncating the entire log for " + 
topicPartition + " in dir " + dir.getParent(),
             () -> {
                 logger.debug("Truncate and start at offset {}", newOffset);
-                checkIfMemoryMappedBufferClosed();
+                checkIfClosed();

Review Comment:
   This is an existing issue. We don't call this in closeQuietly(). Could we 
make it consistent? In any case, it seems that with the current code, it's safe 
to close the segment a second time.



##########
storage/src/main/java/org/apache/kafka/storage/internals/log/LogSegment.java:
##########
@@ -766,19 +762,17 @@ public Optional<FileRecords.TimestampAndOffset> 
findOffsetByTimestamp(long times
      */
     @Override
     public void close() throws IOException {
-        if (maxTimestampAndOffsetSoFar != TimestampOffset.UNKNOWN)
-            Utils.swallow(LOGGER, Level.WARN, "maybeAppend", () -> 
timeIndex().maybeAppend(maxTimestampSoFar(), 
shallowOffsetOfMaxTimestampSoFar(), true));
         Utils.closeAll(lazyOffsetIndex, lazyTimeIndex, log, txnIndex);
     }
 
     /**
-     * Close file handlers used by the log segment but don't write to disk. 
This is used when the disk may have failed
+     * Close the log segment, swallowing any exceptions. This is used when the 
disk may have failed.
      */
-    void closeHandlers() {
-        Utils.swallow(LOGGER, Level.WARN, "offsetIndex", 
lazyOffsetIndex::closeHandler);
-        Utils.swallow(LOGGER, Level.WARN, "timeIndex", 
lazyTimeIndex::closeHandler);
-        Utils.swallow(LOGGER, Level.WARN, "log", log::closeHandlers);
-        Utils.closeQuietly(txnIndex, "txnIndex", LOGGER);
+    void closeQuietly() {
+        Utils.swallow(LOGGER, Level.WARN, "offsetIndex", 
lazyOffsetIndex::close);
+        Utils.swallow(LOGGER, Level.WARN, "timeIndex", lazyTimeIndex::close);
+        Utils.swallow(LOGGER, Level.WARN, "log", log::close);
+        Utils.swallow(LOGGER, Level.WARN, "txnIndex", txnIndex::close);

Review Comment:
   Should we change all swallow() to Utils.closeQuietly?



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