Skip to content
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

Blade c jvm script will be repeated multiple times #150

Closed
auyang-0626 opened this issue Aug 1, 2019 · 3 comments
Closed

Blade c jvm script will be repeated multiple times #150

auyang-0626 opened this issue Aug 1, 2019 · 3 comments
Labels
chaosblade-cli chaosblade project chaosblade-exec-jvm chaosblade-exec-jvm project type/bug Something isn't working
Milestone

Comments

@auyang-0626
Copy link

bug report

./blade c jvm script 会重复挂载多次watch,导致script-file执行多次

通过blade 执行下面的命令多次,第一次成功,之后就报错,看起来没有任何问题。
image
但是观察到脚本被调用了多次,如下图
image
通过阅读源代码发现,每次执行命令,都会走到com.alibaba.chaosblade.exec.bootstrap.jvmsandbox.SandboxModule#add,然后调用sandbox的watch方法添加一个listener。这步完成之后,才会走到判断重复的逻辑,返回错误信息,但是实际上已经再次通过sandbox增强了指定类。
image
image

所以判断重复的操作应该提前进行!

@chaosblade-bot
Copy link
Collaborator

Hi @auyang-0626, we detect non-English characters in the issue. This comment is an auto translation from @chaosblade-bot to help other users to understand this issue.
We encourage you to describe your issue in English which is more friendly to other users.

Blade c jvm script will be repeated multiple times

bug report

./blade c jvm script will repeatedly mount multiple watches, causing script-file to execute multiple times

Execute the following command multiple times through blade, the first success, then the error, it seems that there is no problem.
image
But observed that the script was called multiple times, as shown below
image
By reading the source code, each time you execute the command, you will go to com.alibaba.chaosblade.exec.bootstrap.jvmsandbox.SandboxModule#add, and then call the sandbox watch method to add a listener. After this step is completed, it will go to the logic of judging the repetition and return the error message, but the specified class has actually been enhanced by the sandbox again.
image
image

So judging repeated operations should be done in advance!

@chaosblade-bot chaosblade-bot changed the title blade c jvm script 执行多次会重复 Blade c jvm script will be repeated multiple times Aug 1, 2019
@xcaspar xcaspar added this to the 0.3.0 milestone Aug 1, 2019
@xcaspar
Copy link
Member

xcaspar commented Aug 1, 2019

@auyang-0626 Thanks for reporting the bug. Can you fix it?

xcaspar pushed a commit to chaosblade-io/chaosblade-exec-jvm that referenced this issue Aug 6, 2019
@xcaspar xcaspar closed this as completed Aug 8, 2019
@xcaspar xcaspar added type/bug Something isn't working chaosblade-cli chaosblade project chaosblade-exec-jvm chaosblade-exec-jvm project labels Feb 18, 2020
@No-sleeping
Copy link

bug report

./blade c jvm script 会重复挂载多次watch,导致script-file执行多次

通过blade 执行下面的命令多次,第一次成功,之后就报错,看起来没有任何问题。
image
但是观察到脚本被调用了多次,如下图
image
通过阅读源代码发现,每次执行命令,都会走到com.alibaba.chaosblade.exec.bootstrap.jvmsandbox.SandboxModule#add,然后调用sandbox的watch方法添加一个listener。这步完成之后,才会走到判断重复的逻辑,返回错误信息,但是实际上已经再次通过sandbox增强了指定类。
image
image

所以判断重复的操作应该提前进行!

麻烦问一下,这里注入的脚本是一定要和目标项目打包在一起么?
或者有没有可能麻烦宁发一下您注入脚本的demo呢。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chaosblade-cli chaosblade project chaosblade-exec-jvm chaosblade-exec-jvm project type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants