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

rong pushed a commit to branch fix-pipe-plugin-loader-not-loaded-in-snapshot
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit ee4af58c6a390f3835a6c75dd5fba635095c89b5
Author: Steve Yurong Su <[email protected]>
AuthorDate: Thu Mar 27 16:32:59 2025 +0800

    Pipe Plugin: Fix ClassLoader and Visibility not initialized from CN 
snapshot after reboot
---
 .../persistence/pipe/PipePluginInfo.java           | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git 
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/pipe/PipePluginInfo.java
 
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/pipe/PipePluginInfo.java
index baecc040735..909485f2624 100644
--- 
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/pipe/PipePluginInfo.java
+++ 
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/pipe/PipePluginInfo.java
@@ -352,7 +352,7 @@ public class PipePluginInfo implements SnapshotProcessor {
       final File snapshotFile = new File(snapshotDir, SNAPSHOT_FILE_NAME);
       if (!snapshotFile.exists() || !snapshotFile.isFile()) {
         LOGGER.error(
-            "Failed to load snapshot,snapshot file [{}] is not exist.",
+            "Failed to load snapshot, snapshot file [{}] is not exist.",
             snapshotFile.getAbsolutePath());
         return;
       }
@@ -360,6 +360,26 @@ public class PipePluginInfo implements SnapshotProcessor {
       try (final FileInputStream fileInputStream = new 
FileInputStream(snapshotFile)) {
         pipePluginMetaKeeper.processLoadSnapshot(fileInputStream);
       }
+
+      for (final PipePluginMeta pipePluginMeta : 
pipePluginMetaKeeper.getAllPipePluginMeta()) {
+        final String pluginName = pipePluginMeta.getPluginName();
+        final String pluginDirPath = 
pipePluginExecutableManager.getPluginsDirPath(pluginName);
+        final PipePluginClassLoader pipePluginClassLoader =
+            classLoaderManager.createPipePluginClassLoader(pluginDirPath);
+        try {
+          final Class<?> pluginClass =
+              Class.forName(pipePluginMeta.getClassName(), true, 
pipePluginClassLoader);
+          pipePluginMetaKeeper.addPipePluginVisibility(
+              pluginName, 
VisibilityUtils.calculateFromPluginClass(pluginClass));
+          classLoaderManager.addPluginAndClassLoader(pluginName, 
pipePluginClassLoader);
+        } catch (final Exception e) {
+          LOGGER.warn(
+              "Failed to load plugin class for plugin [{}] when loading 
snapshot [{}] ",
+              pluginName,
+              snapshotFile.getAbsolutePath(),
+              e);
+        }
+      }
     } finally {
       releasePipePluginInfoLock();
     }

Reply via email to