Bug Fix: Defensively copy context entities#340
Merged
NathanielRN merged 3 commits intoaws:masterfrom Jun 27, 2022
Merged
Conversation
4f9b78d to
d070b98
Compare
Contributor
|
Thanks @tyler-dodge! Just curious, do you have a screenshot of this failing or the bug you observed? I think this change makes sense but I think it would be useful to see it breaking. (Or maybe unit tests that show it works if that’s easier to add?). |
Before this change, concurrent async tasks would all share the same instance of the entities list. This change makes it so they each get their own copy of the list. This matters because the recorder modifies the list in place, which makes it so concurrent subtasks have the wrong parent subsegment.
Contributor
Author
|
I added a unit test for it in the latest force push that I also verified failed prior to this change. |
NathanielRN
reviewed
Jun 27, 2022
Co-authored-by: Nathaniel Ruiz Nowell <enruizno@uwaterloo.ca>
NathanielRN
approved these changes
Jun 27, 2022
Contributor
NathanielRN
left a comment
There was a problem hiding this comment.
Thanks so much for your help Tyler! This is a great bug fix and I look forward to seeing it being deployed 🙂
I added some suggestions for documentation to help us in the future, would you mind taking a look? Thanks!
Contributor
Author
|
The modifications you added all look great to me. |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Before this change, concurrent async tasks would all share the same instance of the entities list. This change makes it so they each get their own copy of the list.
This matters because the recorder modifies the
entitieslist in place, which makes it so concurrent subtasks end up looking at the wrong item in theentiteslist when deciding the parent subsegment:aws-xray-sdk-python/aws_xray_sdk/core/context.py
Lines 90 to 101 in 0f13101
You can see this in the unit test added. Before this change the unit test would print out the following:
With this change, all the subsegments have the correct parent ID.
(enowell) You can also visualize this in X-Ray from my tests:
Before:
Subsegments are children of each other even though they are concurrent:
After:
Subsegments have the correct parent ID.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
I think this possibly fixes the issue here:Fixes: #310
Fixes: #164