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

xds:Fix ConcurrentModificationException in PriorityLoadBalancer #9728

Merged
merged 3 commits into from Dec 2, 2022

Conversation

larry-safran
Copy link
Contributor

@larry-safran larry-safran commented Dec 2, 2022

The problem was introduced by pr 9670.

Make a copy of children values to iterate rather than directly using children in for loop

This fixes b/259971157.

@larry-safran larry-safran requested review from temawi and removed request for temawi December 2, 2022 21:12
@larry-safran
Copy link
Contributor Author

Per Eric should not use this approach as want config updates to be atomic

…king copy of children values to iterate rather than directly using children in for loop.
Copy link
Contributor

@temawi temawi left a comment

Choose a reason for hiding this comment

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

Thank you!

Would it be worth adding a comment(s) on why this extra step is needed?

@larry-safran larry-safran enabled auto-merge (squash) December 2, 2022 22:49
@@ -59,6 +61,8 @@ final class PriorityLoadBalancer extends LoadBalancer {

// Includes all active and deactivated children. Mutable. New entries are only added from priority
// 0 up to the selected priority. An entry is only deleted 15 minutes after its deactivation.
// Note that because all configuration updates should be atomic, updates to children can happen
Copy link
Member

Choose a reason for hiding this comment

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

This is incorrect. Updates to children happens within the synchronization context. When this code is running it is already within the synchronization context, so calling into the child can cause the child to call back into the LB policy and modify the map.

Basically, the problem here is a single-threaded mundane "modified while iterating" problem.

@larry-safran larry-safran merged commit 3e5fa7c into grpc:master Dec 2, 2022
@ejona86 ejona86 added the TODO:backport PR needs to be backported. Removed after backport complete label Dec 7, 2022
larry-safran added a commit to larry-safran/grpc-java that referenced this pull request Dec 9, 2022
…#9728)

Fix ConcurrentModificationException in PriorityLoadBalancer by making copy of children values to iterate rather than directly using children in for loop.
larry-safran added a commit that referenced this pull request Dec 12, 2022
… (#9744)

Fix ConcurrentModificationException in PriorityLoadBalancer by making copy of children values to iterate rather than directly using children in for loop.
@ejona86 ejona86 removed the TODO:backport PR needs to be backported. Removed after backport complete label Jan 4, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants