Comments (7)
解决方案:在添加transformer之后,将需要的嵌码类retransform一下
from transmittable-thread-local.
如果没有修改类文件结构,使用retransform transform该类没有任何的问题,以我们探针这么多年的使用经验来说,除了需要短暂的进入safepoint,挂起jvm,没有发现有任何问题,当然进入safepoint是必须的,我觉得可以暂时将ForkJoinPool移除retransform的类列表
from transmittable-thread-local.
使用
TTL Agent
加其他Agent
,TTL Agent
顺序在最后,runnable
无法改成TtlRunnable
@will-zdu 在文档 FAQ 中已说明:
https://github.com/alibaba/transmittable-thread-local/tree/2.x#-faq
Q1.
TTL Agent
与其它Agent
(如Skywalking
、Promethues
)配合使用时不生效?配置
TTL Agent
在最前的位置,可以避免与其它其它Agent
配合使用时,TTL Agent
可能的不生效问题。配置示例:java -javaagent:path/to/transmittable-thread-local-2.x.y.jar \ -javaagent:path/to/skywalking-agent.jar \ -jar your-app.jar原因是:
- 像
Skywalking
这样的Agent
的入口逻辑(premain
)包含了线程池的启动。- 如果配置在这样的
Agent
配置在前面,到了TTL Agent
(的premain
)时,TTL
需要加强的线程池类已经加载(load
)了。TTL Agent
的TtlTransformer
是在类加载时触发类的增强;如果类已经加载了会跳过TTL Agent
的增强逻辑。
解决方案:在添加transformer之后,将需要的嵌码类retransform一下
嗯嗯,欢迎讨论与实现 @will-zdu
from transmittable-thread-local.
@will-zdu PR #526 的实现,你有测试验证过吗(比如在你的应用中可以解决问题)?
这样简单处理可能是不行的,具体可以看看已有的讨论 Issue #226
from transmittable-thread-local.
已经测试验证过了,问题已经解决,当然我只测试了ThreadPoolExecutor类。
我看 #226 里面的讨论是ttl agent会尝试修改类文件结构?如果是这样的话,那确实是存在问题,请问是在那个地方修改了那个类的类文件结构
如果是这样的话,我认为ttl agent这样的修改不太好,修改类的结构在我看来是个不提倡的操作
from transmittable-thread-local.
retransform
让TTL Agent
的实现变复杂了(如类的加载过程),
会引入还不知道的问题要解决(考虑Java Agent
的复杂性),
进而影响TTL Agent
整体的稳定性可靠性。
如果只是解决Agent
配置的顺序问题,推荐配置TTL Agent
到前面吧,简单可靠。 😄 @will-zdu
已经测试验证过了,问题已经解决,当然我只测试了ThreadPoolExecutor类。
当然,你的实现可以自己打个包,在你自己应用中用起来。 💕 @will-zdu
欢迎反馈实现在应用使用中的情况~
我认为ttl agent这样的修改不太好,修改类的结构在我看来是个不提倡的操作
欢迎给出不同的实现与验证 💕
from transmittable-thread-local.
我把代码修改了一下,将ForkJoinPool移除retransform的类列表,这样应该是可以工作了,但是如果别的探针触发了ForkJoinPool的retransform,问题依然是存在的
from transmittable-thread-local.
Related Issues (20)
- TTL使用完成后需要remove掉当前线程的值吗?如果不删除会不会引发OOM? HOT 3
- 主线程执行完后会remove,但是子线程执行完成后会restore恢复本地变量,子线程中的值变量如何清除? HOT 6
- 如何在ttl里面使用BinaryOperator HOT 1
- 使用Java agent不生效,通过arthas jad看对应的类,均已被transform,但是trace不到TtlRunnable和TransmittableThreadLocal的执行记录 HOT 6
- CompletableFuture 指定执行器不生效? HOT 10
- 引入byte-buddy依赖导致Ttl增强失败 HOT 1
- TTL-agent修饰后的ScheduledThreadPoolExecutor的调度任务在取消时,无法从workQueue中清除 HOT 2
- java.lang.IllegalStateException: TTL logger implementation type is already set! type = 0 HOT 2
- java.lang.IllegalStateException: TTL logger implementation type is NOT set! HOT 1
- 2.14.3版本在JDK 21中遇到了类转换异常问题,TTL是否支持JDK 21? HOT 13
- agent 2.14.3 JDK17 报错 HOT 5
- -javaagent:D:\jar\transmittable-thread-local-2.14.0.jar 必须使用带版本号的名称,去除版本号会报错 HOT 1
- k8s环境下CPU调整>2数量后线程上下文传递失效 HOT 1
- 官方maven仓库的版本没有同步? HOT 2
- ListenableFuture添加了监听回调,回调线程获取不到正确的值? HOT 3
- 配合线程池使用时,remove了之后,下一个任务还是能拿到上一个任务设置的值 HOT 1
- 线上运行开始父子线程可以传递threadlocal变量,运行一段时间失效 HOT 1
- 使用jrebel -javaagent方式启动,在stream().parallel()无法正确获取内容
- jdk并发流parallelStream支持这种改造吗 HOT 1
- 在Java21的虚拟线程中不使用`TTL`会有问题吗? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from transmittable-thread-local.