mikemccand commented on code in PR #13206: URL: https://github.com/apache/lucene/pull/13206#discussion_r1539235911
########## lucene/core/src/java/org/apache/lucene/store/NRTCachingDirectory.java: ########## @@ -73,6 +73,7 @@ public class NRTCachingDirectory extends FilterDirectory implements Accountable new SingleInstanceLockFactory(), ByteBuffersDataOutput::new, (fileName, content) -> { + if (!isCachedFile(fileName)) return null; Review Comment: Ahh thank you for the clarification @jpountz. I am playing catchup on this code ;) I think I understand it now. So, this is the `onClose` lambda that is called (when the `IndexOutput` is closed), where we normally increase the `cacheSize` (we do not count the bytes as they are being appended, live, to the file, but rather only when the `IndexOutput` is closed). And we are (newly, with this PR) checking whether it has already been deleted before it was closed and avoiding adding to `cacheSize` in this case. Indeed Lucene should never do this, except maybe in exceptional situations (and even then, hopefully not: Lucene should first close any still-open `IndexOutput`s on exception before delete is tried, I think). +1 to be defensive anyways. Also this is different from the "delete while file is still open for reading" case... -- 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: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org