This is an automated email from the ASF dual-hosted git repository.
jshao 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 3e9080f67f [#7406] fix(core): close H2 backend before deleting files
to prevent file lock issues (#7391)
3e9080f67f is described below
commit 3e9080f67f9b26ecfc38a8ff35e54907074f45fc
Author: 梁自强 <[email protected]>
AuthorDate: Tue Jun 17 00:21:23 2025 +0800
[#7406] fix(core): close H2 backend before deleting files to prevent file
lock issues (#7391)
### What changes were proposed in this pull request?
Ensure that the H2 backend is properly closed before deleting the
database files during test teardown. This avoids file lock exceptions
(e.g., `java.nio.file.FileSystemException
/tmp/gravitino_jdbc_entityStore_95fc02305b9b44a8b1e515d29d453989/testdb.mv.db
The file is being used by another process; the operation cannot access
it.`) caused by open connections when attempting to delete `.mv.db`
files.
### Why are the changes needed?
Fix: test teardown may fail on platforms like Windows due to file locks
if the database is not shut down before deleting files. This change
improves test reliability and aligns with cross-platform resource
management best practices.
Fix: #7406
### Does this PR introduce any user-facing change?
No.
### How was this patch tested?
Ran the affected test suites locally on both Windows and Linux. Verified
that no file lock or deletion failures occur after calling
`backend.close()` before file deletion.
Co-authored-by: Mini Yu <[email protected]>
---
.../java/org/apache/gravitino/storage/relational/TestJDBCBackend.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git
a/core/src/test/java/org/apache/gravitino/storage/relational/TestJDBCBackend.java
b/core/src/test/java/org/apache/gravitino/storage/relational/TestJDBCBackend.java
index 507194671a..0e68c62f1b 100644
---
a/core/src/test/java/org/apache/gravitino/storage/relational/TestJDBCBackend.java
+++
b/core/src/test/java/org/apache/gravitino/storage/relational/TestJDBCBackend.java
@@ -144,6 +144,7 @@ public class TestJDBCBackend {
@AfterAll
public void tearDown() throws IOException {
dropAllTables();
+ backend.close();
File dir = new File(DB_DIR);
if (dir.exists()) {
Files.delete(Paths.get(DB_DIR));
@@ -151,7 +152,6 @@ public class TestJDBCBackend {
Files.delete(Paths.get(H2_FILE));
Files.delete(Paths.get(JDBC_STORE_PATH));
- backend.close();
}
@BeforeEach