You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/09/27 08:39:27 UTC

[GitHub] [iceberg] nastra commented on a diff in pull request #5862: Core: Deflake TestManifestCaching.testWeakFileIOReferenceCleanUp

nastra commented on code in PR #5862:
URL: https://github.com/apache/iceberg/pull/5862#discussion_r980941101


##########
core/src/test/java/org/apache/iceberg/TestManifestCaching.java:
##########
@@ -178,27 +182,27 @@ public void testWeakFileIOReferenceCleanUp() {
 
     System.gc();
     manifestCache.cleanUp();
-    awaitQuiescence();
-    Assert.assertEquals(maxIO, manifestCache.estimatedSize());
     Assert.assertEquals(maxIO, manifestCache.stats().loadCount());
-    Assert.assertEquals(
-        "No entries should be evicted before IO_MANIFEST_CACHE_MAX_FILEIO_DEFAULT exceeded.",
-        0,
-        manifestCache.stats().evictionCount());
 
     // Insert one more FileIO to trigger cache eviction.
     FileIO lastIO = cacheEnabledHadoopFileIO();
     ContentCache lastCache = contentCache(manifestCache, lastIO);
-    System.gc();
-    manifestCache.cleanUp();
-    awaitQuiescence();
+
+    int numGC = 0;
+    int maxGC = 100;
+    while (manifestCache.estimatedSize() > 2 && numGC < maxGC) {
+      System.gc();

Review Comment:
   in general it's not a good practice to depend on repeated (or even single) `System.gc()` calls to make something work.
   I would probably suggest to use https://github.com/google/guava/blob/master/guava-testlib/src/com/google/common/testing/GcFinalization.java#L297 once here instead of plain `System.gc()` calls in a loop



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

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org