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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of grpc: fix data race in balancer registration into release/1.15.x #17351

Commits on May 15, 2023

  1. grpc: fix data race in balancer registration

    Registering gRPC balancers is thread-unsafe because they are stored in a
    global map variable that is accessed without holding a lock. Therefore,
    it's expected that balancers are registered _once_ at the beginning of
    your program (e.g. in a package `init` function) and certainly not after
    you've started dialing connections, etc.
    
    > NOTE: this function must only be called during initialization time
    > (i.e. in an init() function), and is not thread-safe.
    
    While this is fine for us in production, it's challenging for tests that
    spin up multiple agents in-memory. We currently register a balancer per-
    agent which holds agent-specific state that cannot safely be shared.
    
    This commit introduces our own registry that _is_ thread-safe, and
    implements the Builder interface such that we can call gRPC's `Register`
    method once, on start-up. It uses the same pattern as our resolver
    registry where we use the dial target's host (aka "authority"), which is
    unique per-agent, to determine which builder to use.
    boxofrad committed May 15, 2023
    Configuration menu
    Copy the full SHA
    460f861 View commit details
    Browse the repository at this point in the history
  2. Fix linter errors

    boxofrad committed May 15, 2023
    Configuration menu
    Copy the full SHA
    b6d4731 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    b9cdc79 View commit details
    Browse the repository at this point in the history