-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix re-transform bug when enhanced class proxy parent method #659
Conversation
I think this is a general change, rather than fixing Jedis, right? |
Yes, any class that enhances a method from a parent class will have a similar error. |
I want to create an abstract test class that makes it easy to test re-transform in a plug-in module, such as JedisInstrumentationTest. Because of using |
Does this indicate, you are actually testing agent, rather than patch? |
Actually, test re-transforming of plugin |
Yes, then this is a test scenario, I think you could write a plugin test to verify this. It doesn't matter it is about bytebuddy patch or not. |
Write a plugin test to test all plugin maybe difficult, it need to load many classes and some of them are conflicted. |
Then how do you prefer to test this? If there isn't a real agent running. |
I found it does not need to test in real agent, it just need test by re-transform the enhanced class after plugin enhance. Check about |
I did a quick read on |
@kylixs It seems that |
I agree that we should introduce some-how "general" way to test the re-transform mechanism like our E2E for plugins. |
mac+jdk17.Error details: |
Please check error details in file: ${user home}/logs/arthas.log |
I've confirmed that Kafka issue still exists while Redis issue has been resolved.
Error logs shown in
|
After discussing with @kylixs, we've confirmed that this PR works well with Arthas 3.6.7, but not versions > 3.6.7 (including 3.7.1, 3.6.8 etc.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This patch LGTM while we could still improve test coverage (probably in the following PRs)
Could someone submit a ticket to Arthas? I think they could know this quickly as this is just a diff between versions. |
Submitted here alibaba/arthas#2774 |
@kylixs Is this possible to makes tests in agent module, rather than Jedis? And we need to fix change logs, this is not a Jedis fix, but a retransform enhancement, and Arthes compatible fix |
Fixed: alibaba/arthas#2775 |
I prefer to do a separate module ( agent-retransform-tests ), because there are a lot of plugin-related dependencies. The downside is that we need to maintain some associated dependencies when the plug-in changes. |
If that is the case, let's keep the test in the Jedis plugin. But let's make changes.md and PR title accurate. |
Fix re-transform bug when enhanced class proxy parent method
For example, re-transform
Jedis
failed withArthas
: apache/skywalking#11651What happened
redis.clients.jedis.Jedis
withArthas
reported:Open redefine log by:
Analyze with
javap -p
and compare the bytecode before and after retransform, it is found that the field name of the proxy method changes.Found the number of declaration methods returned during retransform is increased and not in the same order. The extra methods comes from the parent class, and the methods are evaluated in a different order each time.
For example, the method
get(byte[])
ofredis.clients.jedis.BinaryJedis
will be added toredis.clients.jedis.Jedis
after jedis plugin is enhanced.How to fix it
SWDescriptionStrategy
: Return original methods in the same order, removing generated methods for delegating superclass calls and others.SWMethodGraphCompilerDelegate
: Sort methods ofMethodGraph
compute from the parent classes.CHANGES
log.