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

[collector] fix dispatch concurrency bug #956

Merged
merged 2 commits into from
May 15, 2023

Conversation

yujianzhong520
Copy link
Contributor

What's changed?

org.dromara.hertzbeat.collector.dispatch.CommonDispatcher 244行
metricsSet.forEach(metricItem -> {});

org.dromara.hertzbeat.common.entity.job.Jon 211 行
if (!metricsSet.remove(metrics)) {
会出现并发错误。

迭代时出现异常,导致监控轮训任务终止。
java.util.ConcurrentModificationException: null at java.base/java.util.HashMap$HashIterator.nextNode(HashMap.java:1510) at java.base/java.util.HashMap$KeyIterator.next(HashMap.java:1533) at java.base/java.lang.Iterable.forEach(Iterable.java:74) at com.usthe.collector.dispatch.CommonDispatcher.dispatchCollectData(CommonDispatcher.java:244)
在Job的getNextCollectMetrics返回一个新的HashSet,避免出现这个问题。

该问题在监控Mysql服务的时候能稳定重现出现。

@yujianzhong520
Copy link
Contributor Author

org.dromara.hertzbeat.common.entity.job.Jon 211 行
改为
org.dromara.hertzbeat.common.entity.job.Job 211 行

@tomsun28 tomsun28 added enhancement New feature or request good first pull request Good for newcomers bugfix labels May 15, 2023
…ob.java

Signed-off-by: tomsun28 <tomsun28@outlook.com>
Copy link
Contributor

@tomsun28 tomsun28 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM.

@tomsun28 tomsun28 changed the title concurrency bug [collector] fix dispatch concurrency bug May 15, 2023
@tomsun28
Copy link
Contributor

@all-contributors please add @yujianzhong520 for code

@allcontributors
Copy link
Contributor

@tomsun28

I've put up a pull request to add @yujianzhong520! 🎉

@tomsun28 tomsun28 merged commit ea717ab into apache:master May 15, 2023
tomsun28 pushed a commit that referenced this pull request Mar 9, 2024
tomsun28 pushed a commit that referenced this pull request Mar 9, 2024
tomsun28 pushed a commit that referenced this pull request Mar 10, 2024
tomsun28 pushed a commit that referenced this pull request Mar 11, 2024
tomsun28 pushed a commit that referenced this pull request Mar 11, 2024
tomsun28 pushed a commit that referenced this pull request Mar 11, 2024
tomsun28 pushed a commit that referenced this pull request Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix enhancement New feature or request good first pull request Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants