davidradl commented on code in PR #26415:
URL: https://github.com/apache/flink/pull/26415#discussion_r2032837282


##########
flink-state-backends/flink-statebackend-forst/src/main/java/org/apache/flink/state/forst/fs/cache/CachedDataInputStream.java:
##########
@@ -102,62 +102,81 @@ private FSDataInputStream getStream() throws IOException {
         if (isFlinkThread()) {
             cacheEntry.touch();
         }
-        FSDataInputStream stream = tryGetCacheStream();
-        if (stream != null) {
-            fileBasedCache.incHitCounter();
-            return stream;
-        }
-
-        if (streamStatus == StreamStatus.CACHED_CLOSED
-                || streamStatus == StreamStatus.CACHED_CLOSING) {
-            if (streamStatus == StreamStatus.CACHED_CLOSING) {
-                try {
-                    semaphore.acquire(1);
-                } catch (InterruptedException e) {
-                    throw new RuntimeException(e);
-                }
-                originalStream.seek(position);
-                position = -1;
-                LOG.trace(
-                        "Stream {} status from {} to {}",
-                        cacheEntry.cachePath,
-                        streamStatus,
-                        StreamStatus.CACHED_CLOSED);
-                streamStatus = StreamStatus.CACHED_CLOSED;
-            }
-            // try reopen
-            tryReopen();
-            stream = tryGetCacheStream();
+        // Repeat until get a stream
+        while (true) {
+            // Firstly, we try to get cache stream
+            FSDataInputStream stream = tryGetCacheStream();
             if (stream != null) {
                 fileBasedCache.incHitCounter();
                 return stream;
             }
-            fileBasedCache.incMissCounter();
-            return originalStream;
-        } else if (streamStatus == StreamStatus.ORIGINAL) {
-            fileBasedCache.incMissCounter();
-            return originalStream;
-        } else {
-            if (streamStatus == StreamStatus.CACHED_OPEN) {
-                stream = tryGetCacheStream();
+
+            // No cache stream, so is it closing?

Review Comment:
   nits:
   You say `No cache stream ` but the cached stream is not null here.
   you say `so is it closing` but this also includes closed.



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