-
Notifications
You must be signed in to change notification settings - Fork 990
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
ConcurrentModificationException when late meter filters are added #5490
ConcurrentModificationException when late meter filters are added #5490
Conversation
@mabartos Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@mabartos Thank you for signing the Contributor License Agreement! |
84e5423
to
828d788
Compare
I wouldn't recommend a We can use |
828d788
to
4c452c9
Compare
@lenin-jaganathan Thanks for the comment.
Ok.
All the writes/removes should be guarded now. @lenin-jaganathan Let me know, if there's a better approach. But resolving this bug is crucial for us as it would need to be propagated to Quarkus as well, so it'd be great to prioritize this issue. |
The CI |
I re-ran the jdk11 job and it passed. I'm not sure if the failures were related to the change or not. |
@shakuzen Got it, thanks! |
I was finally able to figure out a test that reproduces the CME. It wasn't obvious to me at first, but the CME is being thrown because Code: @JCStressTest
@Outcome(id = "true", expect = Expect.ACCEPTABLE, desc = "No exception")
@Outcome(expect = Expect.FORBIDDEN, desc = "ConcurrentModificationException thrown")
@State
public static class ConfigureLateMeterFilterWithNewMeterRegister {
MeterRegistry registry = new SimpleMeterRegistry();
public ConfigureLateMeterFilterWithNewMeterRegister() {
// need the registry to not be empty
registry.counter("c1");
}
@Actor
public void actor1() {
// creates new meter to add to preMap, updating the modCount
registry.counter("c2");
}
@Actor
public void actor2(Z_Result r) {
try {
// adds all the preMap keys to the staleIds, iterating over preMap keys
registry.config().commonTags("common2", "tag2");
r.r1 = true;
} catch (ConcurrentModificationException e) {
r.r1 = false;
}
}
} Results:
|
4c452c9
to
8e6111f
Compare
@shakuzen After applying these changes, the test results are as follows:
Let me know if I can help somehow. |
8e6111f
to
18fa43f
Compare
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.
I left a comment about one of the changes. I have some polish to make for the concurrency test, and we will want to rebase on the 1.13.x
branch so we can release the fix in the next maintenance release, but I can take care of both of these things before merging.
micrometer-core/src/main/java/io/micrometer/core/instrument/MeterRegistry.java
Outdated
Show resolved
Hide resolved
18fa43f
to
6213446
Compare
@shakuzen I updated the code and squashed commits. Created backport for 1.13.x branch: #5496 Not sure how you handle backports, so let me know if I should manage it differently. We need to have the new patch 1.13.x version ASAP to include it in Quarkus and other project. Thanks for your understanding. PS: It seems CI is broken - not related to this PR. |
Not sure they can do that... |
Fixes micrometer-metrics#5489 Co-authored-by: Tommy Ludwig <8924140+shakuzen@users.noreply.github.com> Signed-off-by: Martin Bartoš <mabartos@redhat.com>
6213446
to
2e095b3
Compare
No worries. We merge to the oldest applicable maintenance branch and then merge forward from there. I'll take care of it from here. |
2e095b3
to
a16c72a
Compare
@shakuzen Ok, thank you! |
@lenin-jaganathan You've already mentioned that it should be synchronized, but no action were taken (778f400#r1555315425)
Is it ok to lock it with the
meterMapLock
, or rather use a concurrent collection?