This is an automated email from the ASF dual-hosted git repository.
yuqi1129 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new 24d987cbfb [#10700] test(core): close leaked EntityStore lifecycle for
GC flaky test (#10857)
24d987cbfb is described below
commit 24d987cbfb67fed3bda93af5b954786a04bbcc25
Author: mchades <[email protected]>
AuthorDate: Mon Apr 27 11:27:13 2026 +0800
[#10700] test(core): close leaked EntityStore lifecycle for GC flaky test
(#10857)
### What changes were proposed in this pull request?
This PR fixes flaky interference around function/fileset retention tests
by closing leaked test-side EntityStore lifecycles that start background
RelationalGarbageCollector threads.
Changes:
1. TestPolicyManager
- Promote local EntityStore in @BeforeAll to a class-level field.
- Close it in @AfterAll and set it to null.
2. AbstractEntityStorageTest (PostgreSQL init path)
- Wrap temporary RelationalEntityStore with try-with-resources so it is
always closed after manual cleanup.
### Why are the changes needed?
RelationalEntityStore.initialize() always starts
RelationalGarbageCollector. If test-created stores are not closed,
leaked GC threads can outlive their test class and mutate relational
metadata in later tests, causing intermittent failures (including #10700
symptoms).
Related CI failure example:
-
https://github.com/apache/gravitino/actions/runs/24782154942/job/72516171769
Fix: #10700
### Does this PR introduce _any_ user-facing change?
No. This change only affects test lifecycle management and does not
change production behavior or public APIs.
### How was this patch tested?
- ./gradlew :core:compileTestJava -PskipDockerTests=true
- ./gradlew :core:compileTestJava :core:test --tests
org.apache.gravitino.policy.TestPolicyManager -PskipDockerTests=true
Both commands completed successfully in the fix branch.
---
.../org/apache/gravitino/policy/TestPolicyManager.java | 7 ++++++-
.../gravitino/storage/AbstractEntityStorageTest.java | 17 +++++++++--------
2 files changed, 15 insertions(+), 9 deletions(-)
diff --git
a/core/src/test/java/org/apache/gravitino/policy/TestPolicyManager.java
b/core/src/test/java/org/apache/gravitino/policy/TestPolicyManager.java
index ac76ee81f2..91441d2a3b 100644
--- a/core/src/test/java/org/apache/gravitino/policy/TestPolicyManager.java
+++ b/core/src/test/java/org/apache/gravitino/policy/TestPolicyManager.java
@@ -105,13 +105,14 @@ public class TestPolicyManager {
ImmutableSet.of(
MetadataObject.Type.CATALOG, MetadataObject.Type.SCHEMA,
MetadataObject.Type.TABLE);
+ private static EntityStore entityStore;
private static PolicyManager policyManager;
@BeforeAll
public static void setUp() throws IllegalAccessException, IOException {
IdGenerator idGenerator = new RandomIdGenerator();
Config config = mockConfig();
- EntityStore entityStore = EntityStoreFactory.createEntityStore(config);
+ entityStore = EntityStoreFactory.createEntityStore(config);
entityStore.initialize(config);
policyManager = new PolicyManager(idGenerator, entityStore);
@@ -212,6 +213,10 @@ public class TestPolicyManager {
@AfterAll
public static void tearDown() throws IOException {
+ if (entityStore != null) {
+ entityStore.close();
+ entityStore = null;
+ }
FileUtils.deleteDirectory(new File(JDBC_STORE_PATH));
}
diff --git
a/core/src/test/java/org/apache/gravitino/storage/AbstractEntityStorageTest.java
b/core/src/test/java/org/apache/gravitino/storage/AbstractEntityStorageTest.java
index f91d98c23a..ece352f8ef 100644
---
a/core/src/test/java/org/apache/gravitino/storage/AbstractEntityStorageTest.java
+++
b/core/src/test/java/org/apache/gravitino/storage/AbstractEntityStorageTest.java
@@ -202,14 +202,15 @@ abstract class AbstractEntityStorageTest {
new PostgreSQLExceptionConverter(),
true);
- RelationalEntityStore store =
- (RelationalEntityStore)
EntityStoreFactory.createEntityStore(config);
- store.initialize(config);
- Field f = FieldUtils.getField(RelationalEntityStore.class, "backend",
true);
- RelationalBackend backend = (RelationalBackend) f.get(store);
- RelationalGarbageCollector garbageCollector =
- new RelationalGarbageCollector(backend, config);
- garbageCollector.collectAndClean();
+ try (RelationalEntityStore store =
+ (RelationalEntityStore)
EntityStoreFactory.createEntityStore(config)) {
+ store.initialize(config);
+ Field f = FieldUtils.getField(RelationalEntityStore.class,
"backend", true);
+ RelationalBackend backend = (RelationalBackend) f.get(store);
+ RelationalGarbageCollector garbageCollector =
+ new RelationalGarbageCollector(backend, config);
+ garbageCollector.collectAndClean();
+ }
} else {
throw new UnsupportedOperationException("Unsupported entity store
type: " + type);