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


##########
flink-state-backends/flink-statebackend-forst/src/main/java/org/apache/flink/state/forst/fs/ForStFlinkFileSystem.java:
##########
@@ -126,22 +126,35 @@ public static FileBasedCache getFileBasedCache(
                             + "since the cache and primary path are on the 
same file system.");
             return null;
         }
+        // Create cache directory to make SpaceBasedCacheLimitPolicy works.
+        if (!cacheBase.getFileSystem().mkdirs(cacheBase)) {
+            throw new IOException(
+                    String.format("Could not create ForSt cache directory at 
%s.", cacheBase));
+        }
         CacheLimitPolicy cacheLimitPolicy = null;
         long targetSstFileSize = config.get(TARGET_FILE_SIZE_BASE).getBytes();
-        if (cacheCapacity > 0 && cacheReservedSize >= 0) {
+        boolean useSizeBasedCache = cacheCapacity > 0;
+        // We may encounter the case that the SpaceBasedCacheLimitPolicy 
cannot work properly on
+        // the file system, so we need to check if it works.
+        boolean useSpaceBasedCache =
+                cacheReservedSize > 0
+                        && SpaceBasedCacheLimitPolicy.worksOn(new 
File(cacheBase.toString()));

Review Comment:
   I am not sure how to read this if. 
   `cacheReservedSize > 0`.  - does this mean we have allocated this amount of 
cache already?
   `SpaceBasedCacheLimitPolicy.worksOn` ...   - means there is at least one 
byte free in that File.
   
   is the `cacheReservedSize` the minimum cache?
   If the minimum cache is sufficient then why do we need to check the free 
space for SpaceBasedCacheLimitPolicy.
   
   



-- 
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...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to