divijvaidya commented on code in PR #13850: URL: https://github.com/apache/kafka/pull/13850#discussion_r1229862041
########## core/src/main/scala/kafka/log/remote/RemoteIndexCache.scala: ########## @@ -266,13 +309,21 @@ class RemoteIndexCache(maxSize: Int = 1024, remoteStorageManager: RemoteStorageM getIndexEntry(remoteLogSegmentMetadata).lookupTimestamp(timestamp, startingOffset).position } + /** + * Close should synchronously cleanup the resources used by this cache. + * This index is closed when [[RemoteLogManager]] is closed. + */ def close(): Unit = { - closed = true - cleanerThread.shutdown() - // Close all the opened indexes. - lock synchronized { - entries.values().stream().forEach(entry => entry.close()) + // make close idempotent + if (!closed.getAndSet(true)) { + // Initiate shutdown for cleaning thread + val shutdownRequired = cleanerThread.initiateShutdown() + // Close all the opened indexes to force unload mmap memory. This does not delete the index files from disk. + internalCache.asMap().forEach((_, entry) => entry.close()) + // Perform any pending activities required by the cache for cleanup + internalCache.cleanUp() Review Comment: Great call out. I did not realise that. I do not want removal listener to execute on shutdown. I will not do anything at all here and just let GC clean it up. Am I correct in assuming that no specific "cleanup" is necessary to release the resources acquired by the cache? -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org