-
Notifications
You must be signed in to change notification settings - Fork 714
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
ArrayIndexOutOfBoundsException from MutableSpan #1384
Comments
Hey @karkum , I would like to work on this issue. Can you assign it on me? |
Hello @karkum is anyone working in this? |
I think @reta is looking to remove synchronized for a different concurrent pattern, so whatever is missing here probably a good time to fix it without resurrecting synchronized ;) |
so currently it should be guarded by this in RealSpan @Override public Span tag(String key, String value) {
synchronized (state) {
state.tag(key, value);
}
return this;
} ScopedSpan is unguarded, but that's also documented as not thread safe. The culprit is Tag.tag which accesses the mutable span without synchronizing it. @reta lemme know if you want me to add synchronized to undo later, or if you feel you're close to removing synchronized. I kindof lean towards doing synchronized and releasing a patch to fix it.. |
@codefromthecrypt just picked #1426 up, will address this issue as well, thanks a lot for figuring out the cause (and the fix). |
I was looking into
I think it is rather difficult to fix it it just with |
might have been a red herring.. for example, a user cannot access the mutable span until it is inside a span handler, which should already be locked at that point. sorry if I led you down the wrong path. Basically we don't want to lock fine grained mutablespan as it will explode overhead in ways maybe our benchmarks aren't written to show. If we locked internally in mutablespan, there are existing code which iterate through all things and update many things. So, better to change nothing until sure. |
Thanks @codefromthecrypt
Aha I see, will look more closely into it (definitely not suggesting we locked internally in mutablespan at the moment, I agree) |
The current codebase carefully synchronizes all access to MutableSpan where there can be concurrent use. We missed a spot where Tag.tag is not synchronizing access. The only other place we don't guard is ScopedSpan, which is documented explicitly as not thread safe. Fixes #1384 Signed-off-by: Adrian Cole <adrian@tetrate.io>
The current codebase carefully synchronizes all access to MutableSpan where there can be concurrent use. We missed a spot where Tag.tag is not synchronizing access. The only other place we don't guard is ScopedSpan, which is documented explicitly as not thread safe. Fixes #1384 Signed-off-by: Adrian Cole <adrian@tetrate.io>
The current codebase carefully synchronizes all access to MutableSpan where there can be concurrent use. We missed a spot where Tag.tag is not synchronizing access. The only other place we don't guard is ScopedSpan, which is documented explicitly as not thread safe. Fixes #1384 Signed-off-by: Adrian Cole <adrian@tetrate.io>
Describe the Bug
When adding tags to an ongoing span, we occasionally see the following exception:
I believe this occurs in rare race-conditions in which some tags are removed while others are being added. I will attempt to reproduce this with a test, but I'm not having any luck so far. Wanted to create this issue and see if others are seeing anything similar.
The text was updated successfully, but these errors were encountered: