This is an automated email from the ASF dual-hosted git repository.
danny0405 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git
The following commit(s) were added to refs/heads/master by this push:
new 450bdc80021 [HUDI-9352] Close CompletionTimeQueryView in fsView
(#13238)
450bdc80021 is described below
commit 450bdc80021ac0f0cf44af670d933db7cccfd6b4
Author: Vinish Reddy <[email protected]>
AuthorDate: Wed Apr 30 05:31:12 2025 +0530
[HUDI-9352] Close CompletionTimeQueryView in fsView (#13238)
---
.../common/table/view/AbstractTableFileSystemView.java | 15 +++++++++++----
.../common/table/view/RocksDbBasedFileSystemView.java | 14 ++++++++++----
.../common/table/view/TestHoodieTableFileSystemView.java | 5 +++++
3 files changed, 26 insertions(+), 8 deletions(-)
diff --git
a/hudi-common/src/main/java/org/apache/hudi/common/table/view/AbstractTableFileSystemView.java
b/hudi-common/src/main/java/org/apache/hudi/common/table/view/AbstractTableFileSystemView.java
index fe6192987dd..39558be494b 100644
---
a/hudi-common/src/main/java/org/apache/hudi/common/table/view/AbstractTableFileSystemView.java
+++
b/hudi-common/src/main/java/org/apache/hudi/common/table/view/AbstractTableFileSystemView.java
@@ -300,10 +300,7 @@ public abstract class AbstractTableFileSystemView
implements SyncableFileSystemV
public void close() {
try {
writeLock.lock();
- this.metaClient = null;
- this.completionTimeQueryView = null;
- this.visibleCommitsAndCompactionTimeline = null;
- tableMetadata.close();
+ closeResources();
clear();
} catch (Exception ex) {
throw new HoodieException("Unable to close file system view", ex);
@@ -312,6 +309,16 @@ public abstract class AbstractTableFileSystemView
implements SyncableFileSystemV
}
}
+ protected void closeResources() throws Exception {
+ if (this.completionTimeQueryView != null) {
+ this.completionTimeQueryView.close();
+ this.completionTimeQueryView = null;
+ }
+ this.metaClient = null;
+ this.visibleCommitsAndCompactionTimeline = null;
+ tableMetadata.close();
+ }
+
/**
* Clears the partition Map and reset view states.
* <p>
diff --git
a/hudi-common/src/main/java/org/apache/hudi/common/table/view/RocksDbBasedFileSystemView.java
b/hudi-common/src/main/java/org/apache/hudi/common/table/view/RocksDbBasedFileSystemView.java
index b6626b0659e..c2cac1420ff 100644
---
a/hudi-common/src/main/java/org/apache/hudi/common/table/view/RocksDbBasedFileSystemView.java
+++
b/hudi-common/src/main/java/org/apache/hudi/common/table/view/RocksDbBasedFileSystemView.java
@@ -34,6 +34,7 @@ import org.apache.hudi.common.util.RocksDBSchemaHelper;
import org.apache.hudi.common.util.ValidationUtils;
import org.apache.hudi.common.util.collection.Pair;
import org.apache.hudi.common.util.collection.RocksDBDAO;
+import org.apache.hudi.exception.HoodieException;
import org.apache.hudi.metadata.HoodieTableMetadata;
import org.apache.hudi.storage.StoragePathInfo;
@@ -596,10 +597,15 @@ public class RocksDbBasedFileSystemView extends
IncrementalTimelineSyncFileSyste
@Override
public void close() {
- LOG.info("Closing Rocksdb !!");
- closed = true;
- rocksDB.close();
- LOG.info("Closed Rocksdb !!");
+ try {
+ LOG.info("Closing Rocksdb !!");
+ closed = true;
+ closeResources();
+ rocksDB.close();
+ LOG.info("Closed Rocksdb !!");
+ } catch (Exception e) {
+ throw new HoodieException("Unable to close file system view", e);
+ }
}
@Override
diff --git
a/hudi-hadoop-common/src/test/java/org/apache/hudi/common/table/view/TestHoodieTableFileSystemView.java
b/hudi-hadoop-common/src/test/java/org/apache/hudi/common/table/view/TestHoodieTableFileSystemView.java
index 3d9a8eaef4d..808fe970c3a 100644
---
a/hudi-hadoop-common/src/test/java/org/apache/hudi/common/table/view/TestHoodieTableFileSystemView.java
+++
b/hudi-hadoop-common/src/test/java/org/apache/hudi/common/table/view/TestHoodieTableFileSystemView.java
@@ -67,6 +67,7 @@ import org.apache.hudi.storage.StoragePathInfo;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.permission.FsAction;
import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
@@ -231,6 +232,10 @@ public class TestHoodieTableFileSystemView extends
HoodieCommonTestHarness {
// confirm deleted
assertTrue(deleteReplaceCommit && deleteClusterCommitInflight &&
deleteClusterCommitRequested);
assertDoesNotThrow(() -> fsView.close());
+ if
((fsView.getClass().isAssignableFrom(AbstractTableFileSystemView.class))) {
+ // completionTimeQueryView will be set to null after close.
+ Assertions.assertThrows(NullPointerException.class, () ->
((AbstractTableFileSystemView) fsView).getCompletionTime(""));
+ }
}
protected void testViewForFileSlicesWithNoBaseFile(int expNumTotalFileSlices,