From f8866bf38e9997dfdea454f3a19c036831277e55 Mon Sep 17 00:00:00 2001 From: Anton Okolnychyi Date: Tue, 30 Jan 2024 19:12:17 -0800 Subject: [PATCH] Spark 3.5: Fix flaky TestSparkExecutorCache (#9583) --- .../org/apache/iceberg/spark/TestSparkExecutorCache.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/TestSparkExecutorCache.java b/spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/TestSparkExecutorCache.java index 016319884c3c..189c125b4e3b 100644 --- a/spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/TestSparkExecutorCache.java +++ b/spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/TestSparkExecutorCache.java @@ -70,10 +70,12 @@ import org.apache.iceberg.spark.SparkExecutorCache.Conf; import org.apache.iceberg.util.CharSequenceSet; import org.apache.iceberg.util.Pair; +import org.apache.spark.SparkEnv; import org.apache.spark.sql.Dataset; import org.apache.spark.sql.Encoders; import org.apache.spark.sql.Row; import org.apache.spark.sql.catalyst.analysis.NoSuchTableException; +import org.apache.spark.storage.memory.MemoryStore; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestTemplate; @@ -391,6 +393,11 @@ private List createAndInitTable(String operation, RowLevelOperationM sql("REFRESH TABLE %s", targetTableName); + // invalidate the memory store to destroy all currently live table broadcasts + SparkEnv sparkEnv = SparkEnv.get(); + MemoryStore memoryStore = sparkEnv.blockManager().memoryStore(); + memoryStore.clear(); + return ImmutableList.of(posDeleteFile, eqDeleteFile); }