Manishnemade12 commented on code in PR #27969:
URL: https://github.com/apache/flink/pull/27969#discussion_r3176523339


##########
flink-dstl/flink-dstl-dfs/src/main/java/org/apache/flink/changelog/fs/ChangelogStreamHandleReaderWithCache.java:
##########
@@ -152,11 +156,16 @@ private RefCountedFile 
downloadToCacheFile(FileStateHandle fileHandle) {
     private FileInputStream openAndSeek(RefCountedFile refCountedFile, long 
offset)
             throws IOException {
         FileInputStream fin = new FileInputStream(refCountedFile.getFile());
-        if (offset != 0) {
-            LOG.trace("seek to {}", offset);
-            fin.getChannel().position(offset);
+        try {
+            if (offset != 0) {
+                LOG.trace("seek to {}", offset);
+                fin.getChannel().position(offset);
+            }
+            return fin;
+        } catch (Exception e) {

Review Comment:
   done updated 



##########
flink-dstl/flink-dstl-dfs/src/main/java/org/apache/flink/changelog/fs/ChangelogStreamHandleReaderWithCache.java:
##########
@@ -152,11 +156,16 @@ private RefCountedFile 
downloadToCacheFile(FileStateHandle fileHandle) {
     private FileInputStream openAndSeek(RefCountedFile refCountedFile, long 
offset)
             throws IOException {
         FileInputStream fin = new FileInputStream(refCountedFile.getFile());
-        if (offset != 0) {
-            LOG.trace("seek to {}", offset);
-            fin.getChannel().position(offset);
+        try {
+            if (offset != 0) {
+                LOG.trace("seek to {}", offset);
+                fin.getChannel().position(offset);
+            }
+            return fin;
+        } catch (Exception e) {
+            IOUtils.closeQuietly(fin);
+            throw e;

Review Comment:
   Updated the cached stream open path to release the retained ref-count when 
open/seek fails, so the cache entry does not get stuck above the idle-clean 
threshold.
   Also narrowed the inner seek catch from Exception to IOException.



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