You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "wangbing505 (via GitHub)" <gi...@apache.org> on 2026/09/23 08:57:01 UTC

[I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

wangbing505 opened a new issue, #12456:
URL: https://github.com/apache/seatunnel/issues/12456

   ### Search before asking
   
   - [x] I had searched in the [issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22bug%22) and found no similar issues.
   
   
   ### What happened
   
   使用分离模式集群部署服务,集群作业量也就10个之内,每小时调度一次,一段时间之后就会报错 Caused by: java.lang.OutOfMemoryError: Metaspace
   
   ### SeaTunnel Version
   
   2.3.13
   
   ### SeaTunnel Config
   
   ```conf
   提交作业就会报错,和作业配置无关
   ```
   
   ### Running Command
   
   ```shell
   java -Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector -Dlog4j2.isThreadContextMapInheritable=true -DAsyncLogger.ThreadNameStrategy=UNCACHED -Dhazelcast.logging.type=log4j2 -Dlog4j2.configurationFile=/opt/seatunnel/config/log4j2.properties -Dseatunnel.logs.path=/opt/seatunnel/logs -Dseatunnel.logs.file_name=seatunnel-engine-worker -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/seatunnel/dump/zeta-server -XX:MaxMetaspaceSize=2g -XX:+UseG1GC -Dseatunnel.config=/opt/seatunnel/config/seatunnel.yaml -Dhazelcast.config=/opt/seatunnel/config/hazelcast-worker.yaml -Xms24G -cp /opt/seatunnel/lib/*:/opt/seatunnel/starter/seatunnel-starter.jar org.apache.seatunnel.core.starter.seatunnel.SeaTunnelServer -r worker -DJvmOption=-Xms24G -Xmx24G
   ```
   
   ### Error Exception
   
   ```log
   Caused by: java.lang.OutOfMemoryError: Metaspace
   [] 2026-09-23 14:09:41,089 ERROR [.s.r.f.ExceptionHandlingFilter] [qtp1603729058-28207] - Error occurred while processing request
   org.apache.seatunnel.api.table.factory.FactoryException: ErrorCode:[API-06], ErrorDescription:[Factory initialize failed] - Unable to create a sink for identifier 'Hive'.
   ```
   
   ### Zeta or Flink or Spark Version
   
   _No response_
   
   ### Java or Scala Version
   
   _No response_
   
   ### Screenshots
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "modelpath-dev (via GitHub)" <gi...@apache.org>.
modelpath-dev commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-5870932259

   Looks like the Metaspace is running out of memory over time. Have you checked if there's a memory leak or if the metaspace size needs adjusting?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "wangbing505 (via GitHub)" <gi...@apache.org>.
wangbing505 commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-5889482372

   @DanielLeens  I have already provided the Create and Release classloader logs for a specific job above.
   I submitted a test job to the cluster with the ID 23199974236576. 
   master log message
   `2026-09-29 19:09:58,840 INFO  [.c.c.DefaultClassLoaderService] [qtp1434741143-95] - Create classloader for job 23199974236576 with jars [file:/opt/seatunnel/connectors/connector-mongodb-2.3.12.odeon-2.12.15.jar]
   2026-09-29 19:09:58,840 INFO  [.c.c.DefaultClassLoaderService] [qtp1434741143-95] - Create classloader for job 23199974236576 with jars [file:/opt/seatunnel/connectors/connector-hive-2.3.12.odeon-2.12.15.jar]
   2026-09-29 19:09:58,979 INFO  [.c.c.DefaultClassLoaderService] [qtp1434741143-95] - Release classloader for job 23199974236576 with jars [file:/opt/seatunnel/connectors/connector-mongodb-2.3.12.odeon-2.12.15.jar]
   2026-09-29 19:09:58,992 INFO  [.c.c.DefaultClassLoaderService] [qtp1434741143-95] - Release classloader for job 23199974236576 with jars [file:/opt/seatunnel/connectors/connector-hive-2.3.12.odeon-2.12.15.jar]
   2026-09-29 19:09:59,036 INFO  [.c.c.DefaultClassLoaderService] [seatunnel-coordinator-service-8] - Create classloader for job 23199974236576 with jars [file:/opt/seatunnel/connectors/connector-mongodb-2.3.12.odeon-2.12.15.jar]
   2026-09-29 19:09:59,036 INFO  [.c.c.DefaultClassLoaderService] [seatunnel-coordinator-service-8] - Create classloader for job 23199974236576 with jars []
   2026-09-29 19:09:59,036 INFO  [.c.c.DefaultClassLoaderService] [seatunnel-coordinator-service-8] - Create classloader for job 23199974236576 with jars [file:/opt/seatunnel/connectors/connector-hive-2.3.12.odeon-2.12.15.jar]
   2026-09-29 19:10:00,701 INFO  [.c.c.DefaultClassLoaderService] [seatunnel-coordinator-service-8] - Release classloader for job 23199974236576 with jars [file:/opt/seatunnel/connectors/connector-mongodb-2.3.12.odeon-2.12.15.jar]
   2026-09-29 19:10:00,712 INFO  [.c.c.DefaultClassLoaderService] [seatunnel-coordinator-service-8] - Release classloader for job 23199974236576 with jars []
   2026-09-29 19:10:00,720 INFO  [.c.c.DefaultClassLoaderService] [seatunnel-coordinator-service-8] - Release classloader for job 23199974236576 with jars [file:/opt/seatunnel/connectors/connector-hive-2.3.12.odeon-2.12.15.jar]
   2026-09-29 19:10:00,729 INFO  [.c.c.DefaultClassLoaderService] [seatunnel-coordinator-service-8] - recycle classloader for thread process reaper`
   
   worker log 
   `2026-09-29 19:10:01,173 INFO  [.c.c.DefaultClassLoaderService] [hz.main.generic-operation.thread-45] - Create classloader for job 23199974236576 with jars [file:/opt/seatunnel/connectors/connector-mongodb-2.3.12.odeon-2.12.15.jar]
   2026-09-29 19:10:01,369 INFO  [.c.c.DefaultClassLoaderService] [hz.main.generic-operation.thread-47] - Create classloader for job 23199974236576 with jars [file:/opt/seatunnel/connectors/connector-hive-2.3.12.odeon-2.12.15.jar]
   2026-09-29 19:23:59,169 INFO  [.c.c.DefaultClassLoaderService] [BlockingWorker-TaskGroupLocation{jobId=23199974236576, pipelineId=1, taskGroupId=3}] - Release classloader for job 23199974236576 with jars [file:/opt/seatunnel/connectors/connector-mongodb-2.3.12.odeon-2.12.15.jar]
   2026-09-29 19:23:59,173 INFO  [.c.c.DefaultClassLoaderService] [BlockingWorker-TaskGroupLocation{jobId=23199974236576, pipelineId=1, taskGroupId=3}] - recycle classloader for thread cluster-rtt-ClusterId{value='6abb9d0d9fa4f95b6f42db53', description='null'}-172.30.41.3:27420
   2026-09-29 19:23:59,173 INFO  [.c.c.DefaultClassLoaderService] [BlockingWorker-TaskGroupLocation{jobId=23199974236576, pipelineId=1, taskGroupId=3}] - recycle classloader for thread cluster-ClusterId{value='6abb9d0d9fa4f95b6f42db53', description='null'}-172.30.41.2:27420
   2026-09-29 19:23:59,173 INFO  [.c.c.DefaultClassLoaderService] [BlockingWorker-TaskGroupLocation{jobId=23199974236576, pipelineId=1, taskGroupId=3}] - recycle classloader for thread MaintenanceTimer-5-thread-1
   2026-09-29 19:23:59,173 INFO  [.c.c.DefaultClassLoaderService] [BlockingWorker-TaskGroupLocation{jobId=23199974236576, pipelineId=1, taskGroupId=3}] - recycle classloader for thread cluster-rtt-ClusterId{value='6abb9d0d9fa4f95b6f42db53', description='null'}-172.30.41.4:27420
   2026-09-29 19:23:59,173 INFO  [.c.c.DefaultClassLoaderService] [BlockingWorker-TaskGroupLocation{jobId=23199974236576, pipelineId=1, taskGroupId=3}] - recycle classloader for thread hz.main.seaTunnel.task.thread-14
   2026-09-29 19:23:59,173 INFO  [.c.c.DefaultClassLoaderService] [BlockingWorker-TaskGroupLocation{jobId=23199974236576, pipelineId=1, taskGroupId=3}] - recycle classloader for thread MaintenanceTimer-6-thread-1
   2026-09-29 19:23:59,173 INFO  [.c.c.DefaultClassLoaderService] [BlockingWorker-TaskGroupLocation{jobId=23199974236576, pipelineId=1, taskGroupId=3}] - recycle classloader for thread cluster-rtt-ClusterId{value='6abb9d0d9fa4f95b6f42db53', description='null'}-172.30.41.2:27420
   2026-09-29 19:23:59,173 INFO  [.c.c.DefaultClassLoaderService] [BlockingWorker-TaskGroupLocation{jobId=23199974236576, pipelineId=1, taskGroupId=3}] - recycle classloader for thread BufferPoolPruner-1-thread-1
   2026-09-29 19:23:59,173 INFO  [.c.c.DefaultClassLoaderService] [BlockingWorker-TaskGroupLocation{jobId=23199974236576, pipelineId=1, taskGroupId=3}] - recycle classloader for thread cluster-ClusterId{value='6abb9d0d9fa4f95b6f42db53', description='null'}-172.30.41.3:27420
   2026-09-29 19:23:59,173 INFO  [.c.c.DefaultClassLoaderService] [BlockingWorker-TaskGroupLocation{jobId=23199974236576, pipelineId=1, taskGroupId=3}] - recycle classloader for thread cluster-ClusterId{value='6abb9d0d9fa4f95b6f42db53', description='null'}-172.30.41.4:27420
   2026-09-29 19:23:59,173 INFO  [.c.c.DefaultClassLoaderService] [BlockingWorker-TaskGroupLocation{jobId=23199974236576, pipelineId=1, taskGroupId=3}] - recycle classloader for thread BlockingWorker-TaskGroupLocation{jobId=23199974236576, pipelineId=1, taskGroupId=3}
   2026-09-29 19:23:59,174 INFO  [.c.c.DefaultClassLoaderService] [BlockingWorker-TaskGroupLocation{jobId=23199974236576, pipelineId=1, taskGroupId=3}] - Release classloader for job 23199974236576 with jars [file:/opt/seatunnel/connectors/connector-hive-2.3.12.odeon-2.12.15.jar]
   2026-09-29 19:23:59,176 INFO  [.c.c.DefaultClassLoaderService] [BlockingWorker-TaskGroupLocation{jobId=23199974236576, pipelineId=1, taskGroupId=3}] - recycle classloader for thread ResponseProcessor for block BP-1405345564-172.30.41.51-1706777605594:blk_1119256020_45533959
   2026-09-29 19:23:59,176 INFO  [.c.c.DefaultClassLoaderService] [BlockingWorker-TaskGroupLocation{jobId=23199974236576, pipelineId=1, taskGroupId=3}] - recycle classloader for thread DataStreamer for file /tmp/seatunnel/seatunnel/23199974236576/77aaf92c3e/T_23199974236576_77aaf92c3e_0_1/pdate=2026-09-28/T_23199974236576_77aaf92c3e_0_1.snappy.parquet block BP-1405345564-172.30.41.51-1706777605594:blk_1119256020_45533959
   2026-09-29 19:23:59,176 INFO  [.c.c.DefaultClassLoaderService] [BlockingWorker-TaskGroupLocation{jobId=23199974236576, pipelineId=1, taskGroupId=3}] - recycle classloader for thread hz.main.seaTunnel.task.thread-15
   2026-09-29 19:23:59,176 INFO  [.c.c.DefaultClassLoaderService] [BlockingWorker-TaskGroupLocation{jobId=23199974236576, pipelineId=1, taskGroupId=3}] - recycle classloader for thread LeaseRenewer:hueuser@ns-dev260
   2026-09-29 19:23:59,176 INFO  [.c.c.DefaultClassLoaderService] [BlockingWorker-TaskGroupLocation{jobId=23199974236576, pipelineId=1, taskGroupId=3}] - recycle classloader for thread hz.main.seaTunnel.task.thread-11
   2026-09-29 19:23:59,176 INFO  [.c.c.DefaultClassLoaderService] [BlockingWorker-TaskGroupLocation{jobId=23199974236576, pipelineId=1, taskGroupId=3}] - Cleared 1 Hadoop ReflectionUtils cache entries for released classloader`
   
   <img width="2962" height="612" alt="Image" src="https://github.com/user-attachments/assets/32de6f0c-21b0-42ba-8bf7-702074d0a8e4" />
   
   <img width="2984" height="1332" alt="Image" src="https://github.com/user-attachments/assets/50a2f6ff-9278-4e02-9084-da7ff797f23e" />
   
   While the job was running, I could see that the classLoaderCache size was 1 using the following command:
   
   [arthas@10]$ vmtool --action getInstances --className org.apache.seatunnel.engine.core.classloader.DefaultClassLoaderService --express 'instances[0].classLoaderCache.size()'
   @Integer[1]
   
   The details were as follows:
   
   [arthas@10]$ vmtool --action getInstances --className org.apache.seatunnel.engine.core.classloader.DefaultClassLoaderService --express 'instances[0].classLoaderCache'
   @ConcurrentHashMap[
       @Long[23199974236576]:@ConcurrentHashMap[isEmpty=false;size=2],
   ]
   [arthas@10]$
   
   [arthas@10]$ vmtool --action getInstances --className org.apache.seatunnel.engine.core.classloader.DefaultClassLoaderService --express 'instances[0].classLoaderCache.values().iterator().next().keySet()'
   @KeySetView[
       @String[file:/opt/seatunnel/connectors/connector-mongodb-2.3.12.odeon-2.12.15.jar],
       @String[file:/opt/seatunnel/connectors/connector-hive-2.3.12.odeon-2.12.15.jar],
   ]
   [arthas@10]$
   
   [arthas@10]$ vmtool --action getInstances --className org.apache.seatunnel.engine.core.classloader.DefaultClassLoaderService --express 'instances[0].classLoaderCache.values().iterator().next().values()'
   @ValuesView[
       @SeaTunnelChildFirstClassLoader[org.apache.seatunnel.engine.common.loader.SeaTunnelChildFirstClassLoader@54061fb7],
       @SeaTunnelChildFirstClassLoader[org.apache.seatunnel.engine.common.loader.SeaTunnelChildFirstClassLoader@686faa75],
   ]
   
   Then, after the job finished, we can see that the classLoaderCache size successfully dropped back to 0:
   
   [arthas@10]$ vmtool --action getInstances --className org.apache.seatunnel.engine.core.classloader.DefaultClassLoaderService --express 'instances[0].classLoaderCache.size()'
   @Integer[0]
   
   <img width="2938" height="1170" alt="Image" src="https://github.com/user-attachments/assets/a1cbfb41-760b-43c9-b95e-f5d4eb04a41c" />
   
   This confirms that, for this job, the entry in classLoaderCache was successfully removed after the job completed.
   
   mat 
   I also took a heap dump at this point, then analyzed it using MAT.
   first
   
   <img width="1422" height="790" alt="Image" src="https://github.com/user-attachments/assets/6a75b842-92f0-43b0-b96b-223706ea0d8e" />
   
   second
   
   <img width="1325" height="411" alt="Image" src="https://github.com/user-attachments/assets/98cb9383-2080-43b9-ab89-1a913d6a197e" />
   
   and @SEZ9 After the job finishes, the numberOfInstances of SeaTunnelChildFirstClassLoader does not decrease; it remains at 4. Can’t you see the image in my comment above?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-6392941947

   Thanks @wangbing505 for the 0/5/10-job comparison and the full GC-root paths — that is the key evidence here. The repeated root through Hadoop `ReflectionUtils.CONSTRUCTOR_CACHE` (holding the shaded `SnappyCodec` class defined by the released `SeaTunnelChildFirstClassLoader`) is a process-wide static cache, and the two #12456 cleanup commits already on `dev` (`35b9d5e26d2` and `097101c21be`, as of `4ae4fee30165e9f082f80b05ec5a8f3bb810b474`) do not cover it. They handle the MongoDB pruner, `WritableComparator`, and the `CodecPool` registries, so this remaining root is expected to keep growing per job even on current `dev`. I can't consider the issue resolved until it is handled.
   
   @modelpath-dev — waiting for another snapshot after the job finishes won't change the outcome for this particular root: a static cache entry keyed by the connector's class keeps the loader reachable regardless of job state, so the loader count will not drop on its own. The fix needs to be at the same last-reference release point used by the existing cleaner, removing only `CONSTRUCTOR_CACHE` entries whose key class was defined by the released loader. It must not clear or replace the whole cache, since entries belonging to running jobs or ancestor loaders have to survive.
   
   Concrete remaining asks:
   
   1. A follow-up change that prunes `ReflectionUtils.CONSTRUCTOR_CACHE` entries owned by the released non-cached job loader, alongside the existing registry cleanup.
   2. A regression test with two isolated child class loaders: releasing one must remove only its cache entries while the other loader's entries remain intact.
   3. @wangbing505, once that is in place, please rerun the same 0/5/10-job experiment on a build from current `dev`, trigger a full GC before each reading, and post the exact `SeaTunnelChildFirstClassLoader` counts and Metaspace figures. If any loaders remain, the GC-root paths for those would again be very helpful.
   
   <!-- streview-comment:2019 -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "modelpath-dev (via GitHub)" <gi...@apache.org>.
modelpath-dev commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-6382653622

   Thanks for the detailed insights. I'll wait for the additional snapshot after the job finishes to see if the `SeaTunnelChildFirstClassLoader` instances drop. That should help determine if the classloaders are being released properly or if something else is retaining them.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-5882668611

   @wangbing505 thanks for the Arthas snapshots, they are helpful. They show `SeaTunnelChildFirstClassLoader` instances appearing at submission (2 after the first job, 4 after the second, with `loadedCountTotal` roughly doubling) while the AppClassLoader stays essentially flat, which points at the per-job classloader lifecycle rather than the base worker footprint. Your comment appears to be cut off after "After another 10 minutes," — could you post the rest of that snapshot? The key question is whether the `numberOfInstances` count for `SeaTunnelChildFirstClassLoader` drops back after the jobs finish or stays at 4 and keeps growing with the hourly runs.
   
   What the snapshots don't yet tell us is *why* a loader survives: either the engine never released the classloader for that JAR set, or the release happened but something static or thread-bound still pins it. I'd rather not patch individual registries or change how Hadoop/Parquet classes are loaded until we know which of the two cases this is.
   
   To pin that down, could you provide one sanitized, time-aligned run from the affected worker with:
   
   1. The classloader create/release log lines for each JAR key, plus the reference-count result after the finished job.
   2. If you can take a heap dump, a MAT path-to-GC-roots for one `SeaTunnelChildFirstClassLoader` captured *after* that release.
   3. A minimal repeated reproduction of the failing job with classloader cache mode disabled, so we can confirm it's independent of your production configs.
   
   @modelpath-dev to your question: raising the Metaspace limit would only delay the failure here, since the loader count grows per submission; the evidence so far is consistent with a leak rather than an undersized Metaspace. For wangbing505, enabling classloader cache mode is a reasonable mitigation while the jobs share the same JAR set, but it's not the root-cause fix.
   
   <!-- streview-comment:1395 -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-5869563283

   Classification: A / Zeta class-loader lifecycle and Metaspace.
   
   The new before-and-after snapshots materially improve the evidence: loaders appear at job submission and stop growing while idle, and the finished MongoDB-to-Hive job plus MAT paths point to Hadoop static registries retaining classes loaded by SeaTunnelChildFirstClassLoader. They do not yet prove whether the engine failed to reach a zero reference release or whether a post-release static or thread reference is the retaining root. Current DefaultClassLoaderService already removes a zero-reference non-cache entry and clears matching thread context class loaders, so a per-registry cleanup patch or a broad parent-first Hadoop or Parquet change would be premature and could create dependency-isolation regressions.
   
   Please next provide one sanitized, time-aligned run on the affected worker: Create and Release classloader log lines for each JAR key, the reference-count result after the finished job, and MAT path-to-GC-roots for one loader after that release. Pair this with a minimal repeated MongoDB-to-Hive reproduction under cache mode false. Cache mode true remains a reasonable mitigation for equal JAR sets, not a root-cause fix. Keep #10678 out of production as a blanket workaround until the exact retaining path and safe lifecycle contract are proven.
   
   No label or assignment change in this pass.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-5814905155

   Classification: A / Zeta class-loader lifecycle and Metaspace.\n\nThank you — the new observations materially narrow the investigation. With cache mode disabled, current dev keys DefaultClassLoaderService by job ID and creates a SeaTunnelChildFirstClassLoader for each unseen JAR set; it only removes that entry when releaseClassLoader reaches a zero reference count and clears matching thread context class loaders. The six-to-one INFORMATION_SCHEMA-style ambiguity is not present here: the growing ChildFirst loader count after forced GC means we now need to determine whether releases are not reached, a reference survives release, or new loaders are still being created during the observation window.\n\nChanging classloader-cache-mode to true is a useful mitigation because equal JAR sets share the cache, but it is not yet proof of the retaining path. Please keep monitoring it and do not treat it as a root-cause fix.\n\nFor the next evidence set, please provide sanitized, time-aligned
  snapshots from one affected worker: (1) running job IDs plus ChildFirst loader count and loaded-class total before and after several sequential submissions or restarts; (2) the matching Create classloader and Release classloader log lines for one representative job; and (3) the MAT path-to-GC-roots for two retained ChildFirst loaders, including the owning job/JAR key if visible. A short MongoDB-to-Hive reproduction with cache mode false, followed by a clean job termination, would be especially useful.\n\nI also found open #10678, which proposes an opt-in deep-clean path. Please do not enable or merge it as a blanket workaround for this report: its own description says explicit close is unsafe as the default until residual TCCL/static references are proven safe. The evidence above should decide whether that lifecycle work is relevant here. Keep host names, credentials, keytabs, and full production configuration redacted.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-6459147672

   @wangbing505 Thanks, that plan works. To be plain about status: the `ReflectionUtils.CONSTRUCTOR_CACHE` cleanup is not in place yet, so there is nothing new to test right now. I will ping you on this thread as soon as it lands on `dev` so you can rerun the 0/5/10-job experiment on a build from that state.
   
   When you do rerun it, please keep the same methodology as your earlier snapshots: take each reading after a full GC, and publish the exact `SeaTunnelChildFirstClassLoader` count and Metaspace usage at 0, 5 and 10 jobs. If any loaders are still retained after the final job, a Path to GC Roots for one of them would be very helpful so we can see whether the remaining root is still `CONSTRUCTOR_CACHE` or something else.
   
   @modelpath-dev This should also give you the post-job snapshot you were waiting for to see whether the `SeaTunnelChildFirstClassLoader` instances actually drop once the job finishes. If you have your own run in the meantime, feel free to post the loader counts here too.
   
   <!-- streview-comment:2082 -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "wangbing505 (via GitHub)" <gi...@apache.org>.
wangbing505 commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-6440444835

   @SEZ9 Thanks for the clarification. I'll rerun the 0/5/10-job experiment on a build from the updated dev branch once the ReflectionUtils.CONSTRUCTOR_CACHE cleanup is in place.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "wangbing505 (via GitHub)" <gi...@apache.org>.
wangbing505 commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-6120517443

   ClassLoader counts and memory usage after 0 jobs
   
   <img width="1398" height="416" alt="Image" src="https://github.com/user-attachments/assets/9aeb62dd-fb02-4375-a13e-9934c268ab78" />
   
   ClassLoader counts and memory usage after 5 jobs
   
   <img width="1445" height="474" alt="Image" src="https://github.com/user-attachments/assets/a0b418a5-b388-4699-9418-241c810a32f4" />
   
   ClassLoader counts and memory usage after 10 jobs
   
   <img width="1471" height="406" alt="Image" src="https://github.com/user-attachments/assets/4e549d79-8347-46a7-af28-6fdbb47dae8d" />
   
   2、Path to GC Roots:
   I checked the Path to GC Roots for each of these 20 SeaTunnelChildFirstClassLoader instances individually. The following two paths were duplicated;
   ```text
   Class Name                                                                                                                                                                                                   | Shallow Heap | Retained Heap
   --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   org.apache.seatunnel.engine.common.loader.SeaTunnelChildFirstClassLoader @ 0x865f1c40                                                                                                                        |           88 |       206,848
   '- <classloader> class org.apache.seatunnel.shade.connector.hive.org.apache.parquet.hadoop.codec.SnappyCodec @ 0x8661ad40                                                                                    |            8 |            32
      '- key java.util.concurrent.ConcurrentHashMap$Node @ 0x864a9df0                                                                                                                                           |           32 |           248
         '- next java.util.concurrent.ConcurrentHashMap$Node @ 0x864a9d00                                                                                                                                       |           32 |         1,056
            '- [12] java.util.concurrent.ConcurrentHashMap$Node[32] @ 0x86e3bd88                                                                                                                                |          144 |         6,352
               '- table java.util.concurrent.ConcurrentHashMap @ 0x8529b0b8                                                                                                                                     |           64 |         6,416
                  '- CONSTRUCTOR_CACHE class org.apache.hadoop.util.ReflectionUtils @ 0x850d3038                                                                                                                |           32 |         6,584
                     '- [1542] java.lang.Object[10240] @ 0x86433b40                                                                                                                                             |       40,976 |     2,995,048
                        '- elementData java.util.Vector @ 0x83ca45d8                                                                                                                                            |           32 |     2,995,080
                           '- classes sun.misc.Launcher$AppClassLoader @ 0x84117bf0                                                                                                                             |           88 |     3,898,040
                              |- contextClassLoader com.hazelcast.internal.diagnostics.HealthMonitor$HealthMonitorThread @ 0x83d57068  hz.main.HealthMonitor Thread                                             |          136 |           440
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.slowoperationdetector.SlowOperationDetector$DetectorThread @ 0x83d572b0  hz.main.SlowOperationDetectorThread Thread|          136 |           536
                              |- contextClassLoader com.hazelcast.spi.impl.operationservice.impl.InboundResponseHandlerSupplier$ResponseThread @ 0x83d57438  hz.main.response-1 Thread                          |          144 |         2,576
                              |- contextClassLoader com.hazelcast.spi.impl.operationservice.impl.InboundResponseHandlerSupplier$ResponseThread @ 0x83d57600  hz.main.response-0 Thread                          |          144 |         2,576
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d577c8  hz.main.generic-operation.thread-49 Thread                               |          184 |         5,016
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d57a00  hz.main.generic-operation.thread-48 Thread                               |          184 |         6,328
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d57bb8  hz.main.generic-operation.thread-47 Thread                               |          184 |         6,248
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d57d70  hz.main.generic-operation.thread-46 Thread                               |          184 |        49,608
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d57f28  hz.main.generic-operation.thread-45 Thread                               |          184 |         6,432
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d580e0  hz.main.generic-operation.thread-44 Thread                               |          184 |         5,496
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d58298  hz.main.generic-operation.thread-43 Thread                               |          184 |         6,432
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d58450  hz.main.generic-operation.thread-42 Thread                               |          184 |         5,208
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d58608  hz.main.generic-operation.thread-41 Thread                               |          184 |         5,200
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d587c0  hz.main.generic-operation.thread-40 Thread                               |          184 |         5,312
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d58978  hz.main.generic-operation.thread-39 Thread                               |          184 |         6,456
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d58b30  hz.main.generic-operation.thread-38 Thread                               |          184 |        50,000
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d58ce8  hz.main.generic-operation.thread-37 Thread                               |          184 |        49,504
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d58ea0  hz.main.generic-operation.thread-36 Thread                               |          184 |        49,504
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d59058  hz.main.generic-operation.thread-35 Thread                               |          184 |         5,304
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d59210  hz.main.generic-operation.thread-34 Thread                               |          184 |         6,000
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d593c8  hz.main.generic-operation.thread-33 Thread                               |          184 |         5,240
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d59580  hz.main.generic-operation.thread-32 Thread                               |          184 |        49,752
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d59738  hz.main.generic-operation.thread-31 Thread                               |          184 |         6,616
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d598f0  hz.main.generic-operation.thread-30 Thread                               |          184 |         6,720
                              |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d59aa8  hz.main.generic-operation.thread-29 Thread                               |          184 |         5,496
                              '- Total: 25 of 30 entries; 5 more                                                                                                                                                |              |              
   --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   ```
   
   ```text
   Class Name                                                                                                          | Shallow Heap | Retained Heap
   ---------------------------------------------------------------------------------------------------------------------------------------------------
   org.apache.seatunnel.engine.common.loader.SeaTunnelChildFirstClassLoader @ 0x865d1be8                               |           88 |       120,976
   '- <classloader> class com.mongodb.internal.thread.DaemonThreadFactory @ 0x865ea110                                 |            8 |            48
      '- <class> com.mongodb.internal.thread.DaemonThreadFactory @ 0x85dd8c20                                          |           24 |           136
         '- threadFactory java.util.concurrent.ScheduledThreadPoolExecutor @ 0x868660c8                                |           80 |           680
            '- referent java.lang.ref.Finalizer @ 0x86263d70                                                           |           40 |         9,160
               '- next java.lang.ref.Finalizer @ 0x869bf968                                                            |           40 |         9,200
                  '- next java.lang.ref.Finalizer @ 0x86e3c9e8                                                         |           40 |         9,240
                     '- next java.lang.ref.Finalizer @ 0x86e3ca10                                                      |           40 |         9,280
                        '- next java.lang.ref.Finalizer @ 0x86e3ca38                                                   |           40 |         9,320
                           '- next java.lang.ref.Finalizer @ 0x86e3ca60                                                |           40 |         9,360
                              '- next java.lang.ref.Finalizer @ 0x86e3ca88                                             |           40 |         9,400
                                 '- next java.lang.ref.Finalizer @ 0x86e3cab0                                          |           40 |         9,440
                                    '- next java.lang.ref.Finalizer @ 0x86e3cad8                                       |           40 |         9,480
                                       '- next java.lang.ref.Finalizer @ 0x86e3cb00                                    |           40 |         9,520
                                          '- next java.lang.ref.Finalizer @ 0x86e3cb28                                 |           40 |         9,560
                                             '- next java.lang.ref.Finalizer @ 0x86e3cb50                              |           40 |         9,600
                                                '- next java.lang.ref.Finalizer @ 0x86e3cb78                           |           40 |         9,640
                                                   '- next java.lang.ref.Finalizer @ 0x86e3cba0                        |           40 |         9,680
                                                      '- next java.lang.ref.Finalizer @ 0x86e3cbc8                     |           40 |         9,720
                                                         '- next java.lang.ref.Finalizer @ 0x86e3cbf0                  |           40 |         9,760
                                                            '- next java.lang.ref.Finalizer @ 0x86e3cc18               |           40 |         9,800
                                                               '- next java.lang.ref.Finalizer @ 0x86e3cc40            |           40 |         9,840
                                                                  '- next java.lang.ref.Finalizer @ 0x86e3cc68         |           40 |         9,880
                                                                     '- next java.lang.ref.Finalizer @ 0x86e3cc90      |           40 |         9,920
                                                                        '- next java.lang.ref.Finalizer @ 0x86e3ccb8   |           40 |         9,960
                                                                           '- next java.lang.ref.Finalizer @ 0x86e3cce0|           40 |        10,000
   ---------------------------------------------------------------------------------------------------------------------------------------------------
   ```
   
   each of the remaining paths appeared only once.
   ```text
   Class Name                                                                                                                                                                                       | Shallow Heap | Retained Heap
   --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   org.apache.seatunnel.engine.common.loader.SeaTunnelChildFirstClassLoader @ 0x866ce9c0                                                                                                            |           88 |       207,104
   '- loader java.util.ServiceLoader @ 0x858c3f00                                                                                                                                                   |           32 |           128
      '- renewers class org.apache.hadoop.security.token.Token @ 0x867f2eb0                                                                                                                         |           24 |           216
         '- [5937] java.lang.Object[10240] @ 0x86433b40                                                                                                                                             |       40,976 |     2,995,048
            '- elementData java.util.Vector @ 0x83ca45d8                                                                                                                                            |           32 |     2,995,080
               '- classes sun.misc.Launcher$AppClassLoader @ 0x84117bf0                                                                                                                             |           88 |     3,898,040
                  |- contextClassLoader com.hazelcast.spi.impl.operationservice.impl.InboundResponseHandlerSupplier$ResponseThread @ 0x83d57600  hz.main.response-0 Thread                          |          144 |         2,576
                  |- contextClassLoader com.hazelcast.spi.impl.operationservice.impl.InboundResponseHandlerSupplier$ResponseThread @ 0x83d57438  hz.main.response-1 Thread                          |          144 |         2,576
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.slowoperationdetector.SlowOperationDetector$DetectorThread @ 0x83d572b0  hz.main.SlowOperationDetectorThread Thread|          136 |           536
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d5a340  hz.main.generic-operation.thread-24 Thread                               |          184 |         6,328
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d5a188  hz.main.generic-operation.thread-25 Thread                               |          184 |         6,224
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d59fd0  hz.main.generic-operation.thread-26 Thread                               |          184 |         6,168
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d59e18  hz.main.generic-operation.thread-27 Thread                               |          184 |        49,816
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d59c60  hz.main.generic-operation.thread-28 Thread                               |          184 |         6,328
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d59aa8  hz.main.generic-operation.thread-29 Thread                               |          184 |         5,496
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d598f0  hz.main.generic-operation.thread-30 Thread                               |          184 |         6,720
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d59738  hz.main.generic-operation.thread-31 Thread                               |          184 |         6,616
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d59580  hz.main.generic-operation.thread-32 Thread                               |          184 |        49,752
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d593c8  hz.main.generic-operation.thread-33 Thread                               |          184 |         5,240
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d59210  hz.main.generic-operation.thread-34 Thread                               |          184 |         6,000
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d59058  hz.main.generic-operation.thread-35 Thread                               |          184 |         5,304
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d58ea0  hz.main.generic-operation.thread-36 Thread                               |          184 |        49,504
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d58ce8  hz.main.generic-operation.thread-37 Thread                               |          184 |        49,504
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d58b30  hz.main.generic-operation.thread-38 Thread                               |          184 |        50,000
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d58978  hz.main.generic-operation.thread-39 Thread                               |          184 |         6,456
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d587c0  hz.main.generic-operation.thread-40 Thread                               |          184 |         5,312
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d58608  hz.main.generic-operation.thread-41 Thread                               |          184 |         5,200
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d58450  hz.main.generic-operation.thread-42 Thread                               |          184 |         5,208
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d58298  hz.main.generic-operation.thread-43 Thread                               |          184 |         6,432
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d580e0  hz.main.generic-operation.thread-44 Thread                               |          184 |         5,496
                  |- contextClassLoader com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread @ 0x83d57f28  hz.main.generic-operation.thread-45 Thread                               |          184 |         6,432
                  '- Total: 25 of 30 entries; 5 more                                                                                                                                                |              |              
   --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   
   ```
   
   ```text
   Class Name                                                                                                                 | Shallow Heap | Retained Heap
   ----------------------------------------------------------------------------------------------------------------------------------------------------------
   org.apache.seatunnel.engine.common.loader.SeaTunnelChildFirstClassLoader @ 0x86cd3490                                      |           88 |       206,304
   |- classloader java.security.ProtectionDomain @ 0x86e33e58                                                                 |           40 |            72
   |  '- [4] java.security.ProtectionDomain[5] @ 0x86f472c8                                                                   |           40 |            40
   |     '- context java.security.AccessControlContext @ 0x86f472a0                                                           |           40 |           880
   |        '- inheritedAccessControlContext org.apache.hadoop.util.Daemon @ 0x86f470f8  LeaseRenewer:hueuser@ns-dev260 Thread|          128 |         1,528
   |- <classloader> class org.apache.seatunnel.shade.connector.hive.org.apache.parquet.hadoop.codec.SnappyCodec @ 0x86cee4a0  |            8 |            32
   |  '- key java.util.concurrent.ConcurrentHashMap$Node @ 0x86e3c140                                                         |           32 |           248
   '- Total: 2 entries                                                                                                        |              |              
   ----------------------------------------------------------------------------------------------------------------------------------------------------------
   ```
   
   ```text
   Class Name                                                                                                               | Shallow Heap | Retained Heap
   --------------------------------------------------------------------------------------------------------------------------------------------------------
   org.apache.seatunnel.engine.common.loader.SeaTunnelChildFirstClassLoader @ 0x8663b318                                    |           88 |       206,304
   |- classloader java.security.ProtectionDomain @ 0x85dd7378                                                               |           40 |            80
   |  '- [1] java.security.ProtectionDomain[5] @ 0x85dd7350                                                                 |           40 |            40
   |     '- context java.security.AccessControlContext @ 0x85dd7328                                                         |           40 |         1,432
   |        '- inheritedAccessControlContext java.lang.Thread @ 0x86866118  IPC Parameter Sending Thread #1 Thread          |          120 |         6,320
   |- <classloader> class org.apache.seatunnel.shade.connector.hive.org.apache.parquet.hadoop.codec.SnappyCodec @ 0x86664178|            8 |            32
   '- Total: 2 entries                                                                                                      |              |              
   --------------------------------------------------------------------------------------------------------------------------------------------------------
   
   ```
   
   thread dump after the last job
   执行命令
   jstack -l <pid> > /tmp/threads-12626.txt
   grep -i "ipc\|Parameter Sending" /tmp/threads-12626.txt
   没有找到ipc相关线程


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-6123941681

   Thanks for adding the 0/5/10-job comparison and the complete GC-root paths. This is material new evidence: the repeated root through Hadoop `ReflectionUtils.CONSTRUCTOR_CACHE` is a process-wide static cache holding a class defined by the released connector class loader.
   
   I checked current `dev` at `4ae4fee30165e9f082f80b05ec5a8f3bb810b474`. It contains the two #12456 cleanup commits, `35b9d5e26d2` and `097101c21be`, which clean the MongoDB pruner, `WritableComparator`, and the four `CodecPool` registries when the last reference to a non-cached job loader is released. The cleaner does not currently handle `ReflectionUtils.CONSTRUCTOR_CACHE`, so the new growing root is not covered by those changes. I therefore cannot treat the issue as resolved yet.
   
   A focused follow-up should remove only cache entries whose key class is defined by the released loader, at the same last-reference release point. It must not clear or replace the process-wide cache, because entries belonging to a running job or an ancestor loader must survive.
   
   Please include a regression test with two isolated child class loaders: releasing one must remove only its cache entries while retaining the other loader's entries. Then rerun the same 0/5/10-job experiment on a build from current `dev`, after a full GC, and publish the exact loader-count and Metaspace readings. That will show whether this remaining per-job root is gone without masking a live job's cache.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-5917739187

   Classification: A / Zeta resource management and class-loader lifecycle.
   
   The live-heap paths now provide the missing retaining-edge evidence for the reported 2.3.13 deployment. They identify two different post-release roots: Hadoop's static `WritableComparator.comparators` retains a `Configuration` whose `classLoader` is the released child loader, while MongoDB's live `BufferPoolPruner` thread retains the other child loader through both its thread factory class and inherited access-control context.
   
   This is strong evidence of retention after `releaseClassLoader`, but it does not establish that both roots are present on current `dev`, nor that the opt-in close work in #10678 removes either root. Please do not apply a broad class-loader cleanup or clear a process-wide Hadoop cache based on this one deployment.
   
   The next safe step is two minimal current-`dev` reproducers, one for each root. For each, record the exact connector/JAR set, the loader count and Metaspace before and after a forced GC, the complete textual root path, and the result after one identical second job. A proposed fix must show that it removes only the job-owned reference without breaking another concurrent job that shares Hadoop or MongoDB process state. That evidence will determine whether the fixes should be independent and whether #10678 is relevant to either one.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "wangbing505 (via GitHub)" <gi...@apache.org>.
wangbing505 commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-6056230776

   @DanielLeens  I tried the new fix you submitted. As I mentioned from the beginning, after the previously identified Path to GC Roots was cleaned up, new references appeared.
   
   now, after job finished, Here is the new Path to GC Roots:
   
   ```text
   Class Name                                                                                                     | Shallow Heap | Retained Heap
   ----------------------------------------------------------------------------------------------------------------------------------------------
   org.apache.seatunnel.engine.common.loader.SeaTunnelChildFirstClassLoader @ 0x8626fd38                          |           88 |       275,856
   |- classloader java.security.ProtectionDomain @ 0x8555fae8                                                     |           40 |            80
   |  |- [1] java.security.ProtectionDomain[5] @ 0x8555fe08                                                       |           40 |            40
   |  |  '- context java.security.AccessControlContext @ 0x8555fde0                                               |           40 |            80
   |  |     '- inheritedAccessControlContext java.lang.Thread @ 0x862dbbc0  IPC Parameter Sending Thread #0 Thread|          120 |         4,896
   |  |- [1] java.security.ProtectionDomain[5] @ 0x85561160                                                       |           40 |            40
   |  '- Total: 2 entries                                                                                         |              |
   |- classloader java.security.ProtectionDomain @ 0x862dbe58                                                     |           40 |            72
   |  '- [4] java.security.ProtectionDomain[5] @ 0x8654e908                                                       |           40 |            40
   |- loader java.util.ServiceLoader @ 0x8522aa18                                                                 |           32 |           128
   |  '- renewers class org.apache.hadoop.security.token.Token @ 0x861e47c0                                       |           24 |           216
   '- Total: 3 entries                                                                                            |              |
   ----------------------------------------------------------------------------------------------------------------------------------------------
   ```
   
   another Path to GC Roots:
   
   ```text
   Class Name                                                                                                                                                                                                      | Shallow Heap | Retained Heap
   -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   org.apache.seatunnel.engine.common.loader.SeaTunnelChildFirstClassLoader @ 0x8627b0e8                                                                                                                           |           88 |       166,128
   '- <classloader> class com.mongodb.internal.thread.DaemonThreadFactory @ 0x86289a98                                                                                                                                 |            8 |            48
      '- <class> com.mongodb.internal.thread.DaemonThreadFactory @ 0x85544978                                                                                                                                      |           24 |           136
         '- threadFactory java.util.concurrent.ScheduledThreadPoolExecutor @ 0x862dc2f8                                                                                                                            |           80 |           680
            '- referent java.lang.ref.Finalizer @ 0x85e98560                                                                                                                                                       |           40 |            40
               '- prev java.lang.ref.Finalizer @ 0x85e98538                                                                                                                                                       |           40 |           728
                  '- discovered java.lang.ref.Finalizer @ 0x85e983a8                                                                                                                                               |           40 |           504
                     '- discovered java.lang.ref.Finalizer @ 0x85e98330                                                                                                                                            |           40 |           504
                        '- discovered java.lang.ref.Finalizer @ 0x85e982b8                                                                                                                                         |           40 |           120
                           '- prev, discovered java.lang.ref.Finalizer @ 0x85e98290                                                                                                                                |           40 |           120
                              '- discovered java.lang.ref.Finalizer @ 0x85e97f20                                                                                                                                   |           40 |         7,296
                                 '- discovered com.sun.jna.internal.Cleaner$CleanerRef @ 0x870f8910                                                                                                                |           48 |           136
                                    '- previous com.sun.jna.internal.Cleaner$CleanerRef @ 0x85ddcdc8                                                                                                               |           48 |            72
                                       '- cleanable com.sun.jna.NativeLibrary @ 0x85199f48                                                                                                                         |           56 |           288
                                          '- nativeLibrary com.sun.jna.Library$Handler @ 0x85199f28                                                                                                                |           32 |           696
                                             '- h com.sun.proxy.$Proxy32 @ 0x85199f18                                                                                                                              |           16 |           712
                                                '- INSTANCE class oshi.jna.platform.linux.LinuxLibc @ 0x8621cfc0                                                                                                   |           16 |            96
                                                   '- [4093] java.lang.Object[10240] @ 0x85d073a0                                                                                                                  |       40,976 |     2,659,776
                                                      '- elementData java.util.Vector @ 0x83ca5480                                                                                                                 |           32 |     2,659,808
                                                         '- classes sun.misc.Launcher$AppClassLoader @ 0x83d1f660                                                                                                  |           88 |     3,561,488
                                                            |- scl class java.lang.ClassLoader @ 0x83d0fa88 System Class                                                                                           |           40 |         2,152
                                                            |- scloader class sun.launcher.LauncherHelper @ 0x83d14e98                                                                                             |           80 |           816
                                                            |- contextClassLoader org.apache.logging.log4j.core.util.Log4jThread @ 0x83d646e8  Log4j2-TF-4-Scheduled-2 Thread                                      |          120 |           512
                                                            |- contextClassLoader org.apache.logging.log4j.core.util.Log4jThread @ 0x83d64928  Log4j2-TF-1-AsyncLogger[AsyncContext@2626b418]-1 Thread             |          120 |        30,232
                                                            |- contextClassLoader java.lang.Thread @ 0x83d650c0  Signal Dispatcher Thread                                                                          |          120 |           256
                                                            |- contextClassLoader java.lang.Thread @ 0x862dc580  hz.main.seaTunnel.task.thread-6 Thread                                                            |          120 |         1,616
                                                            |- contextClassLoader java.lang.Thread @ 0x862dc7a8  hz.main.seaTunnel.task.thread-5 Thread                                                            |          120 |        48,824
                                                            |- contextClassLoader java.lang.Thread @ 0x862dc970  hz.main.seaTunnel.task.thread-4 Thread                                                            |          120 |         6,192
                                                            |- contextClassLoader java.lang.Thread @ 0x862dcb48  hz.main.seaTunnel.task.thread-3 Thread                                                            |          120 |         6,832
                                                            |- contextClassLoader java.lang.Thread @ 0x862dcd08  hz.main.seaTunnel.task.thread-2 Thread                                                            |          120 |        32,256
                                                            |- contextClassLoader java.lang.Thread @ 0x862dcec8  hz.main.seaTunnel.task.thread-1 Thread                                                            |          120 |         6,400
                                                            |- contextClassLoader com.hazelcast.internal.util.executor.PoolExecutorThreadFactory$ManagedThread @ 0x862dd088  hz.main.cached.thread-13 Thread       |          136 |         4,896
                                                            |- contextClassLoader com.hazelcast.internal.util.executor.PoolExecutorThreadFactory$ManagedThread @ 0x862dd2a0  hz.main.cached.thread-3 Thread        |          136 |         4,896
                                                            |- contextClassLoader java.lang.Thread @ 0x862dd458  arthas-command-execute Thread                                                                     |          120 |           864
                                                            |- contextClassLoader com.alibaba.arthas.deps.io.netty.util.concurrent.FastThreadLocalThread @ 0x862dd698  arthas-NettyHttpTelnetBootstrap-3-2 Thread  |          128 |         9,184
                                                            |- contextClassLoader java.lang.Thread @ 0x862dd9b8  mcp-keep-alive-scheduler Thread                                                                   |          120 |           200
                                                            |- contextClassLoader java.lang.Thread @ 0x862ddbf8  arthas-session-manager Thread                                                                     |          120 |           200
                                                            |- contextClassLoader java.lang.Thread @ 0x862dde58  arthas-shell-server Thread                                                                        |          120 |           200
                                                            |- contextClassLoader com.alibaba.arthas.deps.io.netty.util.concurrent.FastThreadLocalThread @ 0x862de0b8  arthas-NettyWebsocketTtyBootstrap-4-2 Thread|          128 |         2,192
                                                            |- contextClassLoader com.alibaba.arthas.deps.io.netty.util.concurrent.FastThreadLocalThread @ 0x862de3d8  arthas-NettyWebsocketTtyBootstrap-4-1 Thread|          128 |         2,192
                                                            |- contextClassLoader com.alibaba.arthas.deps.io.netty.util.concurrent.FastThreadLocalThread @ 0x862de6f8  arthas-NettyHttpTelnetBootstrap-3-1 Thread  |          128 |         2,464
                                                            |- contextClassLoader java.util.TimerThread @ 0x862dea70  arthas-timer Thread                                                                          |          128 |           208
                                                            |- contextClassLoader java.lang.Thread @ 0x862dec08  Attach Listener Thread                                                                            |          120 |           680
                                                            |- contextClassLoader com.hazelcast.internal.util.executor.PoolExecutorThreadFactory$ManagedThread @ 0x862ded80  hz.main.cached.thread-4 Thread        |          136 |         4,896
                                                            |- contextClassLoader com.hazelcast.internal.util.executor.PoolExecutorThreadFactory$ManagedThread @ 0x862def38  hz.main.cached.thread-14 Thread       |          136 |         4,896
                                                            '- Total: 25 of 30 entries; 5 more                                                                                                                     |              |
   -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   ```
   
   another Path to GC Roots:
   ```text
   Class Name                                                                                                                                                                      | Shallow Heap | Retained Heap
   ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   org.apache.seatunnel.engine.common.loader.SeaTunnelChildFirstClassLoader @ 0x26b541850                                                                                          |           88 |       276,576
   '- <classloader> class org.apache.seatunnel.shade.connector.hive.org.apache.parquet.hadoop.codec.SnappyCompressor @ 0x26b5474f0                                                 |            8 |           192
      '- key java.util.HashMap$Node @ 0x27c5edef8                                                                                                                                  |           32 |           248
         '- [14] java.util.HashMap$Node[16] @ 0x27c5edea8                                                                                                                          |           80 |           328
            '- table java.util.HashMap @ 0x269cf7350                                                                                                                               |           48 |           376
               '- compressorPool class org.apache.hadoop.io.compress.CodecPool @ 0x26b475c00                                                                                       |           24 |         2,440
                  '- [8100] java.lang.Object[10240] @ 0x26b092c50                                                                                                                  |       40,976 |     2,747,200
                     '- elementData java.util.Vector @ 0x83cf3990                                                                                                                  |           32 |     2,747,232
                        '- classes sun.misc.Launcher$AppClassLoader @ 0x84433ec8                                                                                                   |           88 |     3,649,904
                           |- scl class java.lang.ClassLoader @ 0x844242f0 System Class                                                                                            |           40 |         2,152
                           |- scloader class sun.launcher.LauncherHelper @ 0x84429700 System Class                                                                                 |           80 |           816
                           |- contextClassLoader org.apache.logging.log4j.core.util.Log4jThread @ 0x84479460  Log4j2-TF-4-Scheduled-2 Thread                                       |          120 |           512
                           |- contextClassLoader org.apache.logging.log4j.core.util.Log4jThread @ 0x844796c0  Log4j2-TF-1-AsyncLogger[AsyncContext@2626b418]-1 Thread              |          120 |        30,232
                           |- contextClassLoader java.lang.Thread @ 0x84479e70  Signal Dispatcher Thread                                                                           |          120 |           256
                           |- contextClassLoader java.lang.Thread @ 0x26b5b8808  hz.main.seaTunnel.task.thread-6 Thread                                                            |          120 |         5,784
                           |- contextClassLoader java.lang.Thread @ 0x26b5b8a30  hz.main.seaTunnel.task.thread-5 Thread                                                            |          120 |        48,824
                           |- contextClassLoader java.lang.Thread @ 0x26b5b8bf8  hz.main.seaTunnel.task.thread-4 Thread                                                            |          120 |         6,192
                           |- contextClassLoader java.lang.Thread @ 0x26b5b9068  hz.main.seaTunnel.task.thread-3 Thread                                                            |          120 |         6,832
                           |- contextClassLoader java.lang.Thread @ 0x26b5b9338  hz.main.seaTunnel.task.thread-2 Thread                                                            |          120 |        32,256
                           |- contextClassLoader java.lang.Thread @ 0x26b5b9628  hz.main.seaTunnel.task.thread-1 Thread                                                            |          120 |         6,400
                           |- contextClassLoader java.lang.Thread @ 0x26b5b9918  arthas-command-execute Thread                                                                     |          120 |           864
                           |- contextClassLoader com.alibaba.arthas.deps.io.netty.util.concurrent.FastThreadLocalThread @ 0x26b5b9b78  arthas-NettyHttpTelnetBootstrap-3-2 Thread  |          128 |         9,184
                           |- contextClassLoader java.lang.Thread @ 0x26b5b9e98  mcp-keep-alive-scheduler Thread                                                                   |          120 |           200
                           |- contextClassLoader java.lang.Thread @ 0x26b5ba0f8  arthas-session-manager Thread                                                                     |          120 |           200
                           |- contextClassLoader java.lang.Thread @ 0x26b5ba358  arthas-shell-server Thread                                                                        |          120 |           200
                           |- contextClassLoader com.alibaba.arthas.deps.io.netty.util.concurrent.FastThreadLocalThread @ 0x26b5ba5b8  arthas-NettyWebsocketTtyBootstrap-4-2 Thread|          128 |         2,192
                           |- contextClassLoader com.alibaba.arthas.deps.io.netty.util.concurrent.FastThreadLocalThread @ 0x26b5ba8d8  arthas-NettyWebsocketTtyBootstrap-4-1 Thread|          128 |         2,192
                           |- contextClassLoader com.alibaba.arthas.deps.io.netty.util.concurrent.FastThreadLocalThread @ 0x26b5babf8  arthas-NettyHttpTelnetBootstrap-3-1 Thread  |          128 |         2,464
                           |- contextClassLoader java.util.TimerThread @ 0x26b5baf18  arthas-timer Thread                                                                          |          128 |           208
                           |- contextClassLoader java.lang.Thread @ 0x26b5bb0b0  Attach Listener Thread                                                                            |          120 |           680
                           |- contextClassLoader com.hazelcast.internal.util.executor.PoolExecutorThreadFactory$ManagedThread @ 0x26b5bb228  hz.main.cached.thread-5 Thread        |          136 |         4,896
                           |- contextClassLoader com.hazelcast.internal.util.executor.PoolExecutorThreadFactory$ManagedThread @ 0x26b5bb4a0  hz.main.cached.thread-15 Thread       |          136 |         4,896
                           |- contextClassLoader org.apache.logging.log4j.core.util.Log4jThread @ 0x26b5bb850  Log4j2-TF-4-Scheduled-3 Thread                                      |          120 |           224
                           |- contextClassLoader java.lang.Thread @ 0x26b5bba18  main-NioNetworking-closeListenerExecutor Thread                                                   |          120 |           392
                           '- Total: 25 of 30 entries; 5 more                                                                                                                      |              |              
   ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-6059630871

   Classification: A / Zeta resource-management and class-loader lifecycle. This remains a P0 stability investigation because repeated job cleanup has a demonstrated Metaspace-OOM path.
   
   @wangbing505 thank you for retesting #12626 and supplying the new heap paths. These are not the two roots that PR currently cleans: its cleaner targets the Hadoop `WritableComparator` registry and the MongoDB buffer-pool pruner. It does not establish cleanup ownership for the Hadoop IPC Parameter Sending Thread, ServiceLoader token renewers, `CodecPool`, or the JNA/finalizer chain. #12626 must therefore be treated as partial, not as a general class-loader-leak fix.
   
   Please add, for the exact #12626 commit and the smallest reproducer, a post-job thread dump showing whether the IPC thread is alive, its context class loader, and the owning Hadoop client/RPC object; plus the shortest complete retaining path to a GC root for each remaining loader. Include the connector JAR set, Hadoop/MongoDB versions, number of submit/cancel cycles, and matched before/after heap dumps. That will tell us whether an owner can be safely closed.
   
   Do not add blanket reflection over JVM finalizers, global Hadoop caches, or arbitrary threads. Any follow-up must be one root owner at a time with a real-library regression, preserve still-running jobs and classloader-cache mode, and show that the released loader becomes collectable after the job ends. No label or assignment changed here.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-5892213012

   Classification: A / Zeta class-loader lifecycle and Metaspace.
   
   The new run materially narrows the fault boundary. Its worker logs show both connector loaders being released, and the inspected `classLoaderCache` returns to zero after completion. That rules out an entry merely left in `DefaultClassLoaderService` for this run. Current `dev` removes a non-cache loader at reference count zero and clears matching thread context class loaders, so the surviving four `SeaTunnelChildFirstClassLoader` instances require a retaining path outside that cache entry.
   
   Please do not choose among individual Hadoop-cache cleanup, parent-first loading, or broad classloader redesign yet. The screenshots are useful context but do not provide a searchable retaining-edge record. Please paste the textual MAT Path to GC Roots for one post-release loader, including every strong-reference field/object edge and the retaining thread or static owner if one exists. Pair it with the final reference count and the same observation after one more identical job. That will distinguish a surviving static cache, a live thread or ThreadLocal, and another root without guessing. Cache mode for equal JAR sets remains a mitigation, not a root-cause fix.
   
   No label or assignment change in this pass.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "wangbing505 (via GitHub)" <gi...@apache.org>.
wangbing505 commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-5807180004

   1. **Relationship with `classloader-cache-mode`**
   
   It is currently difficult to provide the complete logs. However, based on our analysis, the issue appears to be related to the `classloader-cache-mode` configuration.
   
   Previously, `classloader-cache-mode` was configured as `false`, mainly because we wanted to support plugin updates without restarting the entire cluster service.
   
   We have now changed it to `true`, and so far the issue appears to be resolved. We are continuing to monitor the cluster to confirm whether this change can consistently prevent the problem.
   
   2. **Java Version**
   
   The current Java version is:
   
   ```text
   java version "1.8.0_202"
   Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
   Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
   ```
   
   3. **Arthas and MAT Analysis**
   
   We used Arthas for further analysis. The most abnormal classloader is:
   
   ```text
   org.apache.seatunnel.engine.common.loader.SeaTunnelChildFirstClassLoader
   ```
   
   The initial `classloader` output was:
   
   ```text
   [arthas@9]$ classloader
    name                                                                      numberOfInstances  loadedCountTotal
    org.apache.seatunnel.engine.common.loader.SeaTunnelChildFirstClassLoader  191                210597
    sun.misc.Launcher$AppClassLoader                                          1                  12042
    BootstrapClassLoader                                                      1                  3712
    com.taobao.arthas.agent.ArthasClassloader                                 1                  2385
    sun.reflect.DelegatingClassLoader                                         689                689
    sun.misc.Launcher$ExtClassLoader                                         1                  44
    sun.reflect.misc.MethodUtil                                               1                  1
   Affect(row-cnt:7) cost in 197 ms.
   ```
   
   We then executed:
   
   ```text
   vmtool --action forceGc
   ```
   
   However, there was no obvious change in the number of `SeaTunnelChildFirstClassLoader` instances or the total number of loaded classes.
   
   After the forced GC, the output became:
   
   ```text
   [arthas@9]$ classloader
   name numberOfInstances loadedCountTotal
   org.apache.seatunnel.engine.common.loader.SeaTunnelChildFirstClassLoader 225 250131
   sun.misc.Launcher$AppClassLoader 1 12046
   BootstrapClassLoader 1 3757
   com.taobao.arthas.agent.ArthasClassloader 1 3473
   sun.reflect.DelegatingClassLoader 894 894
   sun.misc.Launcher$ExtClassLoader 1 44
   sun.reflect.misc.MethodUtil 1 1
   Affect(row-cnt:7)
   cost in 157 ms.
   ```
   
   This suggests that the `SeaTunnelChildFirstClassLoader` instances and the classes loaded by them were not reclaimed by GC. The number of classloader instances and loaded classes actually continued to increase.
   
   We also used MAT to analyze the heap dump and investigate the references retaining these classloaders. a litter demo
   
   The MAT analysis results are shown in the attached screenshots:
   
   <img width="1208" height="284" alt="Image" src="https://github.com/user-attachments/assets/cfd31507-5b62-40b6-83c3-f0166abfc27b" />
   
   <img width="1038" height="197" alt="Image" src="https://github.com/user-attachments/assets/110dd963-c9e1-4c0b-a949-7d7afa642d18" />
   
   <img width="1066" height="181" alt="Image" src="https://github.com/user-attachments/assets/76f56616-2929-4142-be8e-3655ed2a793f" />
   
   <img width="1161" height="163" alt="Image" src="https://github.com/user-attachments/assets/c01997b2-13bd-45a4-9bf9-5e94b9e7665a" />
   
   4. **Currently Installed Connectors**
   
   The currently installed connectors are:
   
   ```text
   connectors["connector-cdc-base"]="seatunnel-connectors-v2/connector-cdc/connector-cdc-base"
   connectors["connector-cdc-mysql"]="seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql"
   connectors["connector-cdc-mongodb"]="seatunnel-connectors-v2/connector-cdc/connector-cdc-mongodb"
   
   # connectors["connector-iceberg"]="seatunnel-connectors-v2/connector-iceberg"
   # connectors["connector-hudi"]="seatunnel-connectors-v2/connector-hudi"
   # connectors["connector-paimon"]="seatunnel-connectors-v2/connector-paimon"
   # connectors["connector-fake"]="seatunnel-connectors-v2/connector-fake"
   # connectors["connector-jdbc"]="seatunnel-connectors-v2/connector-jdbc"
   
   connectors["connector-hive"]="seatunnel-connectors-v2/connector-hive"
   
   # connectors["connector-console"]="seatunnel-connectors-v2/connector-console"
   # connectors["connector-kafka"]="seatunnel-connectors-v2/connector-kafka"
   
   connectors["connector-file-hadoop"]="seatunnel-connectors-v2/connector-file/connector-file-hadoop"
   connectors["connector-file-ftp"]="seatunnel-connectors-v2/connector-file/connector-file-ftp"
   connectors["connector-file-obs"]="seatunnel-connectors-v2/connector-file/connector-file-obs"
   connectors["connector-file-sftp"]="seatunnel-connectors-v2/connector-file/connector-file-sftp"
   
   # connectors["connector-mongodb"]="seatunnel-connectors-v2/connector-mongodb"
   # connectors["connector-elasticsearch"]="seatunnel-connectors-v2/connector-elasticsearch"
   ```
   
   At the moment, the only type of job we are submitting is:
   
   ```text
   MongoDB -> Hive
   ```
   
   Based on the current observations, we suspect that when `classloader-cache-mode=false`, plugin classloaders may be continuously created during job submission/execution and are not being garbage-collected as expected.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-6073517148

   Classification: A / Zeta class-loader lifecycle and Metaspace.
   
   @wangbing505 thank you for retesting #12626 and for the new root paths. To keep the scope honest: #12626 is a partial change. It only releases the MongoDB `PowerOfTwoBufferPool` pruner and the Hadoop `WritableComparator.comparators` configuration. It is not a general class-loader-leak fix, and I am not adding more cleanup to it until the data below shows which remaining roots actually grow per job.
   
   What the library sources say (Hadoop 3.1.4, MongoDB driver 4.7.1; this is source reading, not a reproduction):
   
   1. `Token.renewers` is a static `ServiceLoader` created in `Token`'s static initializer. It captures the thread context class loader once, when `Token` is first initialized. It can pin one job loader for the life of the JVM, but it does not grow per job.
   2. `Client.ClientExecutorServiceFactory` creates a static cached thread pool ("IPC Parameter Sending Thread #N", 60s idle timeout). A pooled thread keeps the access control context of the thread that created it, so it pins the loader of the job that created it while it lives. That is also one loader at a time, not one per job.
   3. The `DaemonThreadFactory` path in your second dump goes only through `java.lang.ref.Finalizer` / JNA `CleanerRef` `discovered` links. A `ScheduledThreadPoolExecutor` is finalizable on Java 8, so this looks like an executor that has been shut down (the pruner is stopped by #12626) and is waiting for finalization, not a live root. This is an inference; Arthas `forceGc` runs a single GC, and finalizable objects need a further cycle.
   
   None of this shows that the `SeaTunnelChildFirstClassLoader` count still grows per job on the #12626 build, which is what drives the Metaspace OOM. Please provide, from one worker running the #12626 build with cache mode false:
   
   1. The `SeaTunnelChildFirstClassLoader` count and Metaspace used after 0, 5 and 10 sequential identical MongoDB-to-Hive jobs, each after a forced GC.
   2. A heap dump taken with `jmap -dump:live` after two GCs and `System.runFinalization()` (for example via `vmtool`), and the path to GC roots for one loader that is still present.
   3. A thread dump after the last job showing whether the IPC Parameter Sending Thread is alive and its context class loader.
   
   If the count is flat or grows by a small constant, the remaining roots are bounded and the remaining work is documentation or a targeted single-owner fix. If it still grows per job, the retaining path from the dump will tell us which owner to close next, with a real-library regression. `classloader-cache-mode=true` stays a valid mitigation for identical JAR sets. No label or assignment change in this pass.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-5923303163

   @wangbing505 Thanks for the MAT path — that is the retaining edge we were missing. Reading it: the system `AppClassLoader` holds the `WritableComparator` class, its static `comparators` map holds a `Text$Comparator`, whose `conf` is a Hadoop `Configuration`, and the `classLoader` field of that `Configuration` pins the `SeaTunnelChildFirstClassLoader`. So this looks like a process-wide Hadoop static outliving `releaseClassLoader`, rather than a leak inside the SeaTunnel loader itself. It is consistent with what we saw in our 2.3.13 / Java 8u342 / `classloader-cache-mode=false` investigation with repeated MongoDB → Hive jobs.
   
   Nothing has been changed yet based on this; I don't want to clear Hadoop's static cache globally, since another concurrent job sharing Hadoop state could be using it. To turn this into a targeted fix, could you provide:
   
   1. The full, untruncated path (the paste cuts off at `AppClassLoader`), and, since it is labelled "first", any further paths for other retained loaders.
   2. Confirmation that the same path shows up on the latest code with a minimal repro: exact connector/JAR set, loader count and Metaspace before/after a forced GC, and whether the `comparators` entry still points at the released loader after running one identical second job (does it stay at one stale loader, or grow by one per job?).
   3. Your `classloader-cache-mode` setting for the run that produced this dump.
   
   With that we can decide whether re-binding the `Configuration` classloader (or creating it outside the job loader) is enough, and whether any other roots need independent fixes.
   
   <!-- streview-comment:1434 -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "wangbing505 (via GitHub)" <gi...@apache.org>.
wangbing505 commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-5907224237

   mat   Path to GC Roots
   first
   ```text
   Class Name                                                                                                                                                                        | Shallow Heap | Retained Heap
   -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   org.apache.seatunnel.engine.common.loader.SeaTunnelChildFirstClassLoader @ 0x86295230                                                                                             |           88 |       276,432
   '- classLoader org.apache.hadoop.conf.Configuration @ 0x851a6070                                                                                                                  |           40 |           240
      '- conf org.apache.hadoop.io.Text$Comparator @ 0x851a6050                                                                                                                      |           32 |            32
         '- val java.util.concurrent.ConcurrentHashMap$Node @ 0x851a6030                                                                                                             |           32 |            64
            '- [0] java.util.concurrent.ConcurrentHashMap$Node[16] @ 0x851a5fe0                                                                                                      |           80 |           144
               '- table java.util.concurrent.ConcurrentHashMap @ 0x851a5fa0                                                                                                          |           64 |           208
                  '- comparators class org.apache.hadoop.io.WritableComparator @ 0x862886f0                                                                                          |            8 |           240
                     '- [1656] java.lang.Object[10240] @ 0x85d34e98                                                                                                                  |       40,976 |     2,673,208
                        '- elementData java.util.Vector @ 0x83ca5d30                                                                                                                 |           32 |     2,673,240
                           '- classes sun.misc.Launcher$AppClassLoader @ 0x83d1ff58                                                                                                  |           88 |     3,575,792
                              |- scl class java.lang.ClassLoader @ 0x83d10380 System Class                                                                                           |           40 |         2,152
                              |- scloader class sun.launcher.LauncherHelper @ 0x83d15790 System Class                                                                                |           80 |           816
                              |- contextClassLoader org.apache.logging.log4j.core.util.Log4jThread @ 0x83d65268  Log4j2-TF-4-Scheduled-2 Thread                                      |          120 |           512
                              |- contextClassLoader org.apache.logging.log4j.core.util.Log4jThread @ 0x83d654a8  Log4j2-TF-1-AsyncLogger[AsyncContext@2626b418]-1 Thread             |          120 |        30,232
                              |- contextClassLoader java.lang.Thread @ 0x83d65c40  Signal Dispatcher Thread                                                                          |          120 |           256
                              |- contextClassLoader java.lang.Thread @ 0x86300fb0  arthas-command-execute Thread                                                                     |          120 |           864
                              |- contextClassLoader com.alibaba.arthas.deps.io.netty.util.concurrent.FastThreadLocalThread @ 0x863011f0  arthas-NettyHttpTelnetBootstrap-3-2 Thread  |          128 |         9,184
                              |- contextClassLoader java.lang.Thread @ 0x86301510  mcp-keep-alive-scheduler Thread                                                                   |          120 |           200
                              |- contextClassLoader java.lang.Thread @ 0x86301750  arthas-session-manager Thread                                                                     |          120 |           200
                              |- contextClassLoader java.lang.Thread @ 0x86301990  arthas-shell-server Thread                                                                        |          120 |           200
                              |- contextClassLoader com.alibaba.arthas.deps.io.netty.util.concurrent.FastThreadLocalThread @ 0x86301bd0  arthas-NettyWebsocketTtyBootstrap-4-2 Thread|          128 |         2,192
                              |- contextClassLoader com.alibaba.arthas.deps.io.netty.util.concurrent.FastThreadLocalThread @ 0x86301ef0  arthas-NettyWebsocketTtyBootstrap-4-1 Thread|          128 |         2,192
                              |- contextClassLoader com.alibaba.arthas.deps.io.netty.util.concurrent.FastThreadLocalThread @ 0x86302210  arthas-NettyHttpTelnetBootstrap-3-1 Thread  |          128 |         2,464
                              |- contextClassLoader java.util.TimerThread @ 0x86302530  arthas-timer Thread                                                                          |          128 |           208
                              |- contextClassLoader java.lang.Thread @ 0x863026c8  Attach Listener Thread                                                                            |          120 |           680
                              |- contextClassLoader com.hazelcast.internal.util.executor.PoolExecutorThreadFactory$ManagedThread @ 0x863028e0  hz.main.cached.thread-11 Thread       |          136 |         4,896
                              |- contextClassLoader com.hazelcast.internal.util.executor.PoolExecutorThreadFactory$ManagedThread @ 0x86302a98  hz.main.cached.thread-6 Thread        |          136 |         4,896
                              |- contextClassLoader com.hazelcast.internal.util.executor.PoolExecutorThreadFactory$ManagedThread @ 0x86302c50  hz.main.cached.thread-16 Thread       |          136 |         4,896
                              |- contextClassLoader org.apache.logging.log4j.core.util.Log4jThread @ 0x86302e08  Log4j2-TF-4-Scheduled-3 Thread                                      |          120 |           512
                              |- contextClassLoader com.hazelcast.internal.diagnostics.HealthMonitor$HealthMonitorThread @ 0x86303128  hz.main.HealthMonitor Thread                  |          136 |           440
                              |- contextClassLoader java.lang.Thread @ 0x863032b0  Connector-Scheduler-10c47c79-1 Thread                                                             |          120 |           376
                              |- contextClassLoader java.lang.Thread @ 0x863034f0  hz.main.TcpServer.thread-4 Thread                                                                 |          120 |           432
                              |- contextClassLoader java.lang.Thread @ 0x86303750  hz.main.TcpServer.thread-3 Thread                                                                 |          120 |           432
                              |- contextClassLoader java.lang.Thread @ 0x86303918  hz.main.TcpServer.thread-2 Thread                                                                 |          120 |           432
                              |- contextClassLoader java.lang.Thread @ 0x86303ae0  hz.main.TcpServer.thread-1 Thread                                                                 |          120 |           432
                              |- contextClassLoader com.hazelcast.internal.server.tcp.TcpServerAcceptor$AcceptorIOThread @ 0x86303ca8  hz.main.IO.thread-Acceptor Thread             |          128 |           384
                              |- contextClassLoader com.hazelcast.internal.networking.nio.iobalancer.IOBalancerThread @ 0x86303f00  hz.main.IO.BalancerThread Thread                 |          144 |           456
                              |- contextClassLoader com.hazelcast.internal.networking.nio.NioThread @ 0x863040f8  hz.main.IO.thread-out-2 Thread                                     |          216 |         4,872
                              |- contextClassLoader com.hazelcast.internal.networking.nio.NioThread @ 0x86304388  hz.main.IO.thread-out-1 Thread                                     |          216 |         4,872
                              |- contextClassLoader com.hazelcast.internal.networking.nio.NioThread @ 0x86304618  hz.main.IO.thread-out-0 Thread                                     |          216 |         4,848
                              '- Total: 30 entries                                                                                                                                   |              |              
   -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   ```
   second
   ```text
   Class Name                                                                                                 | Shallow Heap | Retained Heap
   ------------------------------------------------------------------------------------------------------------------------------------------
   org.apache.seatunnel.engine.common.loader.SeaTunnelChildFirstClassLoader @ 0x8629fc70                      |           88 |       165,488
   |- <classloader> class com.mongodb.internal.thread.DaemonThreadFactory @ 0x862ae620                        |            8 |            48
   |  '- <class> com.mongodb.internal.thread.DaemonThreadFactory @ 0x855c06f0                                 |           24 |           136
   |     '- threadFactory java.util.concurrent.ScheduledThreadPoolExecutor @ 0x86300e18                       |           80 |           480
   |        |- <Java Local> java.lang.Thread @ 0x86300c68  BufferPoolPruner-1-thread-1 Thread                 |          120 |           640
   |        |- this$0 java.util.concurrent.ThreadPoolExecutor$Worker @ 0x86300e78                             |           48 |            48
   |        |- this$0 java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask @ 0x855c07c8       |           72 |           112
   |        |- referent java.lang.ref.Finalizer @ 0x86158a18                                                  |           40 |            40
   |        '- Total: 4 entries                                                                               |              |              
   |- classloader java.security.ProtectionDomain @ 0x8630f530                                                 |           40 |           400
   |  '- [1] java.security.ProtectionDomain[2] @ 0x855c08c0                                                   |           24 |            24
   |     '- context java.security.AccessControlContext @ 0x855c0898                                           |           40 |            64
   |        '- inheritedAccessControlContext java.lang.Thread @ 0x86300c68  BufferPoolPruner-1-thread-1 Thread|          120 |           640
   '- Total: 2 entries                                                                                        |              |              
   ------------------------------------------------------------------------------------------------------------------------------------------
   ```
   
   Collected using heapdump --live (i.e., the set of objects that remain alive after GC).
   The heap dump was taken after the job had completely finished. Both of the following ClassLoader instances were present in the live object set, meaning they remained alive even after a full GC had occurred after the job finished.
   Leak #1 — Retained by a static field (Hadoop WritableComparator)
   MAT “Path to GC Roots”, with weak/soft/phantom references excluded.
   The following path is expanded from the GC Root toward the retained object, with the strong-reference field name annotated at each hop:
   ```text
   [GC Root] sun.misc.Launcher$AppClassLoader @ 0x83d1ff58
     --(field classes)-->           java.util.Vector @ 0x83ca5d30
     --(field elementData)-->       java.lang.Object[10240] @ 0x85d34e98   [index 1656]
     -->                            class org.apache.hadoop.io.WritableComparator @ 0x862886f0
     --(static field comparators)--> java.util.concurrent.ConcurrentHashMap @ 0x851a5fa0   <== static holder
     --(field table)-->             ConcurrentHashMap$Node[16] @ 0x851a5fe0   [index 0]
     --(field val)-->               ConcurrentHashMap$Node @ 0x851a6030
     -->                            org.apache.hadoop.io.Text$Comparator @ 0x851a6050
     --(field conf)-->              org.apache.hadoop.conf.Configuration @ 0x851a6070
     --(field classLoader)-->       SeaTunnelChildFirstClassLoader @ 0x86295230   <== leaked object
                                     (shallow 88 / retained 276,432)
   Retention type: Static cache
   Static holder: org.apache.hadoop.io.WritableComparator.comparators (static ConcurrentHashMap)
   ```
   Leak #2 — Retained by a live thread (MongoDB Driver BufferPoolPruner)
   The second surviving ClassLoader instance in the same dump.
   MAT “Path to GC Roots”, with weak/soft/phantom references excluded.
   There are two independent strong-reference paths, but both ultimately originate from the same live thread:
   ```text
   [GC Root] java.lang.Thread @ 0x86300c68  "BufferPoolPruner-1-thread-1"  (alive)
       |
       |-- Branch A --
       |
       --(Java Local)-->             java.util.concurrent.ScheduledThreadPoolExecutor @ 0x86300e18
       --(field threadFactory)-->    com.mongodb.internal.thread.DaemonThreadFactory @ 0x855c06f0
       --(<class>)-->                class com.mongodb.internal.thread.DaemonThreadFactory @ 0x862ae620
       --(<classloader>)-->          SeaTunnelChildFirstClassLoader @ 0x8629fc70   <== leaked object
                                     (shallow 88 / retained 165,488)
       |
       |-- Branch B --
       |
       --(field inheritedAccessControlContext)--> java.security.AccessControlContext @ 0x855c0898
       --(field context)-->           java.security.ProtectionDomain[2] @ 0x855c08c0  [index 1]
       -->                            java.security.ProtectionDomain @ 0x8630f530
       --(field classloader)-->       SeaTunnelChildFirstClassLoader @ 0x8629fc70   <== same object
   ```
   Retention type: Live thread
   Thread: "BufferPoolPruner-1-thread-1" (still running after the job finished)
   Static holder: None; this path does not involve a static field.
   
   and, For another job execution, after performing another heap dump, the two additional SeaTunnelChildFirstClassLoader instances have the same “Path to GC Roots” in MAT. the final reference count is zero
   
   @SEZ9 ClassLoader count and Metaspace usage before and after job execution.
   ```text
   [arthas@9]$ classloader
    name                                                                      numberOfInstances  loadedCountTotal
    sun.misc.Launcher$AppClassLoader                                          1                  10577
    com.taobao.arthas.agent.ArthasClassloader                                 2                  4764
    BootstrapClassLoader                                                      1                  3703
    org.apache.seatunnel.engine.common.loader.SeaTunnelChildFirstClassLoader  2                  2320
    sun.reflect.DelegatingClassLoader                                         253                253
    sun.misc.Launcher$ExtClassLoader                                          1                  44
    sun.reflect.misc.MethodUtil                                               1                  1
   Affect(row-cnt:7) cost in 15 ms.
   [arthas@9]$
   [arthas@9]$ memory
   Memory                                                                                     used                          total                         max                            usage
   heap                                                                                       937M                          2048M                         30688M                         3.06%
   g1_eden_space                                                                              856M                          1244M                         -1                             68.81%
   g1_survivor_space                                                                          0K                            0K                            -1                             0.00%
   g1_old_gen                                                                                 81M                           804M                          30688M                         0.27%
   nonheap                                                                                    156M                          163M                          3312M                          4.73%
   code_cache                                                                                 26M                           26M                           240M                           10.85%
   metaspace                                                                                  116M                          122M                          2048M                          5.69%
   compressed_class_space                                                                     13M                           15M                           1024M                          1.37%
   direct                                                                                     546K                          546K                          -                              100.00%
   mapped                                                                                     4K                            4K                            -                              100.00%
   [arthas@9]$
   [arthas@9]$
   [arthas@9]$ classloader
    name                                                                      numberOfInstances  loadedCountTotal
    sun.misc.Launcher$AppClassLoader                                          1                  10606
    com.taobao.arthas.agent.ArthasClassloader                                 2                  4765
    org.apache.seatunnel.engine.common.loader.SeaTunnelChildFirstClassLoader  4                  4638
    BootstrapClassLoader                                                      1                  3704
    sun.reflect.DelegatingClassLoader                                         279                279
    sun.misc.Launcher$ExtClassLoader                                          1                  44
    sun.reflect.misc.MethodUtil                                               1                  1
   Affect(row-cnt:7) cost in 27 ms.
   [arthas@9]$
   [arthas@9]$
   [arthas@9]$ memory
   Memory                                                                                     used                          total                         max                            usage
   heap                                                                                       1169M                         2048M                         30688M                         3.81%
   g1_eden_space                                                                              1088M                         1244M                         -1                             87.46%
   g1_survivor_space                                                                          0K                            0K                            -1                             0.00%
   g1_old_gen                                                                                 81M                           804M                          30688M                         0.27%
   nonheap                                                                                    172M                          180M                          3312M                          5.21%
   code_cache                                                                                 27M                           27M                           240M                           11.39%
   metaspace                                                                                  129M                          136M                          2048M                          6.34%
   compressed_class_space                                                                     15M                           16M                           1024M                          1.51%
   direct                                                                                     640K                          640K                          -                              100.00%
   mapped                                                                                     4K                            4K                            -                              100.00%
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-6137262379

   @wangbing505 thanks for the 0/5/10-job comparison and for walking the Path to GC Roots for each of the 20 `SeaTunnelChildFirstClassLoader` instances. The repeated path you posted is the key piece: the shaded `SnappyCodec` class, defined by a released connector loader, is still held as a key in a process-wide `ConcurrentHashMap` (Hadoop `ReflectionUtils.CONSTRUCTOR_CACHE`), which pins the whole loader and its Metaspace.
   
   To keep the scope honest about what is already in `dev` (`4ae4fee30165e9f082f80b05ec5a8f3bb810b474`): the two cleanup commits for this issue, `35b9d5e26d2` and `097101c21be`, clear the MongoDB pruner, `WritableComparator`, and the four `CodecPool` registries when the last reference to a non-cached job loader is released. They do not touch `ReflectionUtils.CONSTRUCTOR_CACHE`, so the root you found is not covered and #12456 cannot be treated as resolved yet. #12626 remains a partial fix.
   
   Concrete asks for the follow-up:
   
   1. Extend the existing last-reference release path so it removes only `CONSTRUCTOR_CACHE` entries whose key class was defined by the loader being released. Please do not clear or swap the whole static map — entries belonging to running jobs or ancestor loaders must survive.
   2. Add a regression test with two isolated child class loaders: releasing one must drop only its own cache entries while the other loader's entries remain present.
   3. Rebuild from current `dev` with that change, rerun the same 0/5/10-job experiment, trigger a full GC before each reading, and post the exact `SeaTunnelChildFirstClassLoader` counts and Metaspace numbers. If any loader is still retained, please attach its Path to GC Roots the same way you did here.
   
   That will tell us whether this remaining per-job root is gone without masking a live job's cache.
   
   <!-- streview-comment:1713 -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-5794529186

   Classification: A / Zeta runtime memory (Metaspace).
   
   Thanks for the report. The evidence currently establishes that the worker reaches the configured 2 GiB Metaspace ceiling while the Hive sink factory is being created; it does not yet identify which class loader, generated class, or repeatedly loaded artifact is retaining the metadata. The large Java heap settings do not diagnose a Metaspace exhaustion.
   
   Could you add a short English or bilingual summary (to keep the report searchable), then provide the following from the affected worker, with credentials and private host names redacted:
   
   1. the full worker log from process start to the first OOM, plus the matching master log;
   2. `java -version`, the effective JVM flags, and whether workers/jobs are restarted or re-submitted repeatedly before the failure;
   3. `jcmd <pid> VM.classloader_stats` and `jcmd <pid> GC.class_histogram` shortly before/after the growth, or the generated heap dump if it is available; and
   4. the installed connector/plugin JAR inventory and whether the failure happens only when a Hive sink is present.
   
   Those artifacts distinguish a class-loader retention issue from a Hive/Hadoop dependency-loading problem or a deployment-level repeated-JAR load. Please do not post secrets, keytabs, or full production configuration. Once we have that evidence, we can reproduce the narrow path and decide whether a code fix is needed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "wangbing505 (via GitHub)" <gi...@apache.org>.
wangbing505 commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-5889597020

   @modelpath-dev My analysis suggests that this is a classloader leak, because the Metaspace usage keeps increasing and does not decrease.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "knight6236 (via GitHub)" <gi...@apache.org>.
knight6236 commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-5902619531

   We investigated a related classloader-retention scenario using SeaTunnel **2.3.13**, **Java 8u342**, and `classloader-cache-mode=false`, with repeated MongoDB → Hive jobs included in our existing E2E matrix.
   
   Your observation that `classLoaderCache` returns to zero is important: removing the loader from that cache does not necessarily make it collectible if other objects still retain it.
   
   In our reproduction, MAT analysis and source inspection identified additional retention paths involving MongoDB buffer-pool maintenance and Hadoop resources, including `CodecPool`, `ReflectionUtils`, the token renewer `ServiceLoader`, and shared DFS/RPC objects retaining job classloaders through thread context or configuration references. These are findings from **our test environment**; we have not established that every path is present in your heap dump.
   
   We implemented targeted cleanup in [[LingFrame SeaTunnel Agent](https://github.com/LingFrame/LingFrame-Seatunnel-Agent)], which we maintain, and compared it against an unmodified SeaTunnel instance. In one completed A/B run, each side executed **105 jobs across a mixed connector matrix**, including MongoDB → Hive. After job completion and forced GC:
   
   | Measurement | Without agent | With agent |
   |---|---:|---:|
   | Remaining `SeaTunnelChildFirstClassLoader` instances | 567 | 0 |
   | Metaspace used | ~620 MiB | ~90 MiB |
   
   This demonstrates classloader reclamation for that test workload, rather than proof of long-term stability or an upstream fix. Our environment also differs from your separated master/worker deployment and Java version. We have additionally observed intermittent job-status timeouts in CI that remain under investigation.
   
   The reproduction and cleanup implementation are available in the repository above for review. We are sharing these results to help narrow the post-release retention paths in this issue.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-5902826430

   @wangbing505 Thanks for the Create/Release classloader log lines for job 23199974236576. The log shows both connector loaders (MongoDB and Hive) being created and then released for that job, and together with your observation that Metaspace usage keeps increasing without coming back down, I agree this looks like a classloader leak rather than an undersized Metaspace; raising the Metaspace limit would only delay the OOM, not fix it.
   
   What the release log does not tell us is what still holds a strong reference to the released `SeaTunnelChildFirstClassLoader` instances so they cannot be collected. To pin that down, it would help to have:
   
   1. From a heap dump taken after the job finished (and after a forced GC), the textual MAT "Path to GC Roots" (excluding weak/soft references) for one surviving loader, including every field/object edge and the owning thread or static holder at the root.
   2. The loader count and Metaspace used right after that job, and again after running one more identical job, so we can see whether it grows per job.
   
   @knight6236 Thanks for the detailed A/B data. The retention paths you list (MongoDB buffer-pool maintenance, Hadoop `CodecPool` / `ReflectionUtils` / token renewer `ServiceLoader`, shared DFS/RPC objects via thread context or configuration references) are exactly the kind of roots that would explain a loader surviving after release. As you note, those come from your environment, so we should not assume every path applies here; the GC-root output from this deployment will show which of them (if any) are present before we decide on a fix upstream.
   
   <!-- streview-comment:1415 -->


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug] [enigne] Caused by: java.lang.OutOfMemoryError: Metaspace [seatunnel]

Posted by "wangbing505 (via GitHub)" <gi...@apache.org>.
wangbing505 commented on issue #12456:
URL: https://github.com/apache/seatunnel/issues/12456#issuecomment-5862488423

   Thank you for your response.
   
   ### ClassLoader comparison before and after job submission
   
   Before submitting the job:
   
   ```text
   [arthas@9]$ classloader
    name                                       numberOfInstances  loadedCountTotal
    sun.misc.Launcher$AppClassLoader           1                  7657
    BootstrapClassLoader                       1                  3454
    com.taobao.arthas.agent.ArthasClassloader  1                  2364
    sun.reflect.DelegatingClassLoader          152                152
    sun.misc.Launcher$ExtClassLoader           1                  42
    sun.reflect.misc.MethodUtil                1                  1
   
   Affect(row-cnt:6) cost in 11 ms.
   ```
   
   After submitting the first job:
   
   ```text
   [arthas@9]$ classloader
    name                                                                      numberOfInstances  loadedCountTotal
    sun.misc.Launcher$AppClassLoader                                          1                  10586
    BootstrapClassLoader                                                      1                  3693
    com.taobao.arthas.agent.ArthasClassloader                                 1                  2364
    org.apache.seatunnel.engine.common.loader.SeaTunnelChildFirstClassLoader  2                  2320
    sun.reflect.DelegatingClassLoader                                         245                245
    sun.misc.Launcher$ExtClassLoader                                          1                  44
    sun.reflect.misc.MethodUtil                                               1                  1
   
   Affect(row-cnt:7) cost in 13 ms.
   ```
   
   After submitting another job:
   
   ```text
   [arthas@9]$ classloader
    name                                                                      numberOfInstances  loadedCountTotal
    sun.misc.Launcher$AppClassLoader                                          1                  10610
    org.apache.seatunnel.engine.common.loader.SeaTunnelChildFirstClassLoader  4                  4643
    BootstrapClassLoader                                                      1                  3694
    com.taobao.arthas.agent.ArthasClassloader                                 1                  2367
    sun.reflect.DelegatingClassLoader                                         271                271
    sun.misc.Launcher$ExtClassLoader                                          1                  44
    sun.reflect.misc.MethodUtil                                               1                  1
   
   Affect(row-cnt:7) cost in 12 ms.
   ```
   
   After another 10 minutes, with no new jobs submitted, the number of `SeaTunnelChildFirstClassLoader` instances did not increase:
   
   ```text
   [arthas@9]$ classloader
    name                                                                      numberOfInstances  loadedCountTotal
    sun.misc.Launcher$AppClassLoader                                          1                  10655
    org.apache.seatunnel.engine.common.loader.SeaTunnelChildFirstClassLoader  4                  4645
    BootstrapClassLoader                                                      1                  3694
    com.taobao.arthas.agent.ArthasClassloader                                 1                  2367
    sun.reflect.DelegatingClassLoader                                         271                271
    sun.misc.Launcher$ExtClassLoader                                          1                  44
    sun.reflect.misc.MethodUtil                                               1                  1
   
   Affect(row-cnt:7) cost in 18 ms.
   ```
   
   This seems to indicate that the `SeaTunnelChildFirstClassLoader` instances are primarily created when new jobs are submitted, rather than continuously increasing during idle periods.
   
   ### Job information
   
   The Job ID is:
   
   ```text
   23184458863328
   ```
   
   I used the following command to check the job status across the cluster:
   
   ```text
   ./bin/seatunnel.sh -j 23184458863328
   ```
   
   The result was:
   
   ```json
   {
     "jobId": 23184458863328,
     "jobName": "local_test_mongo2hive_0615_08_copy_copy",
     "jobStatus": "FINISHED",
     "submitTime": 1790558985229,
     "startTime": 1790558986875,
     "finishTime": 1790558992144,
     "pipelineStateMapperMap": {
       "PipelineLocation(jobId=23184458863328, pipelineId=1)": {
         "pipelineStatus": "FINISHED",
         "executionStateMap": {
           "TaskGroupLocation{jobId=23184458863328, pipelineId=1, taskGroupId=1}": "FINISHED",
           "TaskGroupLocation{jobId=23184458863328, pipelineId=1, taskGroupId=2}": "FINISHED",
           "TaskGroupLocation{jobId=23184458863328, pipelineId=1, taskGroupId=3}": "FINISHED"
         }
       }
     },
     "errorMessage": null,
     "project": "dataex_dev_project"
   }
   ```
   log message
   
   <img width="1634" height="210" alt="Image" src="https://github.com/user-attachments/assets/8f13c251-c22b-4e17-805d-a3c6e28394b6" />
   
   ### Relevant logs and MAT analysis
   
   I also took a heap dump at this point, then analyzed it using MAT.
   
   first
   <img width="1422" height="790" alt="Image" src="https://github.com/user-attachments/assets/1bd0c366-b324-40cb-bec7-1ea572b84bb8" />
   
   second
   <img width="1325" height="411" alt="Image" src="https://github.com/user-attachments/assets/6379748c-05d3-4eac-bcb0-fdcd2d05b919" />
   
   The first retained `ChildFirstClassLoader` is particularly difficult to deal with.
   
   I previously tried to explicitly clean up these references inside `releaseClassLoader`. However, after cleaning up one reference chain, another reference from a different Hadoop class appeared and retained the ClassLoader again.
   
   The current analysis shows the following:
   
   After removing A/B/C and checking the heap again, two new chains with essentially the same pattern appeared:
   
   * `CodecPool.compressorCounts`: this is still related to `CodecPool`, but this time it is a Guava `LocalCache` rather than a `java.util.Map`. Therefore, the previous `(Map)` cast and `removeClassKeyedEntriesLoadedBy` logic cannot cover this case. This appears to be exactly why the same type of reference shows up again in the latest MAT analysis.
   
   * `WritableComparator.comparators`: another Hadoop static registry that retains classes loaded by the child ClassLoader.
   
   There seem to be many long-lived Hadoop static structures whose keys are Classes loaded by the child ClassLoader, such as `SerializationFactory`, `Groups`, and others.
   
   The exact structures also vary depending on the Hadoop version. In some versions they are regular Maps, while in others they may be Guava caches. Handling each one individually would therefore require continuously adding special cases.
   
   After seeing the same pattern appear in multiple rounds of analysis, I think this is becoming an architectural signal rather than an isolated reference leak.
   
   Instead of continuing to remove individual references one by one, I am considering a more fundamental approach: making the Parquet compression-related classes be loaded by the parent ClassLoader, so that the keys in these long-lived Hadoop static registries are associated with the parent ClassLoader rather than the `SeaTunnelChildFirstClassLoader`. In that case, these static registries would no longer retain the SeaTunnel child ClassLoader.
   
   ### Questions
   
   Based on the above observations, do you have any recommended approaches for addressing this ClassLoader retention problem?
   
   In particular, I would like to understand whether we should:
   
   1. Continue cleaning up individual Hadoop static references during `releaseClassLoader`;
   2. Change the ClassLoader relationship so that certain Hadoop/Parquet classes are loaded by the parent ClassLoader;
   3. Focus on identifying and stopping engine-side threads such as `BufferPoolPruner` that retain the child ClassLoader;
   4. Or consider a more systematic lifecycle/design change for `SeaTunnelChildFirstClassLoader`.
   
   Any suggestions on the recommended direction would be greatly appreciated.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org