-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Conversation
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.
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.
Thank you!
Would it be worth adding a comment(s) on why this extra step is needed?
@@ -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 |
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.
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.
…#9728) Fix ConcurrentModificationException in PriorityLoadBalancer by making copy of children values to iterate rather than directly using children in for loop.
… (#9744) Fix ConcurrentModificationException in PriorityLoadBalancer by making copy of children values to iterate rather than directly using children in for loop.
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.