[ https://issues.apache.org/jira/browse/HADOOP-18184?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17746629#comment-17746629 ]
ASF GitHub Bot commented on HADOOP-18184: ----------------------------------------- steveloughran commented on code in PR #5832: URL: https://github.com/apache/hadoop/pull/5832#discussion_r1272698192 ########## hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/impl/prefetch/CachingBlockManager.java: ########## @@ -298,16 +306,26 @@ public void requestPrefetch(int blockNumber) { /** * Requests cancellation of any previously issued prefetch requests. + * If the reason was switching to random IO, any active prefetched blocks + * are still cached. + * @param reason why? */ @Override - public void cancelPrefetches() { + public void cancelPrefetches(final CancelReason reason) { + LOG.debug("Cancelling prefetches {}", reason); BlockOperations.Operation op = ops.cancelPrefetches(); - for (BufferData data : bufferPool.getAll()) { - // We add blocks being prefetched to the local cache so that the prefetch is not wasted. - if (data.stateEqualsOneOf(BufferData.State.PREFETCHING, BufferData.State.READY)) { - requestCaching(data); + if (reason == CancelReason.RandomIO) { + for (BufferData data : bufferPool.getAll()) { + // We add blocks being prefetched to the local cache so that the prefetch is not wasted. + // this only done if the reason is random IO-related, not due to close/unbuffer + if (data.stateEqualsOneOf(BufferData.State.PREFETCHING, BufferData.State.READY)) { + requestCaching(data); + } } + } else { + // free the buffers + bufferPool.getAll().forEach(BufferData::setDone); Review Comment: we had so much grief with the abfs prefetch premature release bug that I am scared now > s3a prefetching stream to support unbuffer() > -------------------------------------------- > > Key: HADOOP-18184 > URL: https://issues.apache.org/jira/browse/HADOOP-18184 > Project: Hadoop Common > Issue Type: Sub-task > Components: fs/s3 > Affects Versions: 3.4.0 > Reporter: Steve Loughran > Assignee: Steve Loughran > Priority: Minor > Labels: pull-request-available > > Apache Impala uses unbuffer() to free up all client side resources held by a > stream, so allowing it to have a map of available (path -> stream) objects, > retained across queries. > This saves on having to reopen the files, with the cost of HEAD checks etc. > S3AInputStream just closes its http connection. here there is a lot more > state to discard, but all memory and file storage must be freed. > until this done, ITestS3AContractUnbuffer must skip when the prefetch stream > is used. > its notable that the other tests don't fail, even though the stream doesn't > implement the interface; the graceful degradation handles that. it should > fail if the test xml resource says the stream does it, but that the stream > capabilities say it doesn't. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org