This is an automated email from the ASF dual-hosted git repository.

jshao pushed a commit to branch branch-0.9
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/branch-0.9 by this push:
     new 2ab463a26d [#7406] fix(core): close H2 backend before deleting files 
to prevent file lock issues (#7408)
2ab463a26d is described below

commit 2ab463a26dadc25db21d8956d5ed88a4cc20bf1b
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Mon Jun 16 11:36:19 2025 -0700

    [#7406] fix(core): close H2 backend before deleting files to prevent file 
lock issues (#7408)
    
    ### 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: 梁自强 <[email protected]>
    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

Reply via email to