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

grpc logger data race #10

Open
sveatlo opened this issue Jun 24, 2021 · 1 comment
Open

grpc logger data race #10

sveatlo opened this issue Jun 24, 2021 · 1 comment

Comments

@sveatlo
Copy link
Contributor

sveatlo commented Jun 24, 2021

==================
WARNING: DATA RACE
Read at 0x0000017f13c0 by goroutine 31:
  google.golang.org/grpc/internal/grpclog.InfoDepth()
      /home/sveatlo/src/go/pkg/mod/google.golang.org/[email protected]/internal/grpclog/grpclog.go:34 +0x3e
  google.golang.org/grpc/grpclog.(*componentData).InfoDepth()
      /home/sveatlo/src/go/pkg/mod/google.golang.org/[email protected]/grpclog/component.go:36 +0x1a5
  google.golang.org/grpc/internal/channelz.AddTraceEvent()
      /home/sveatlo/src/go/pkg/mod/google.golang.org/[email protected]/internal/channelz/funcs.go:301 +0x2f0
  google.golang.org/grpc/internal/channelz.Infof()
      /home/sveatlo/src/go/pkg/mod/google.golang.org/[email protected]/internal/channelz/logging.go:45 +0x137
  google.golang.org/grpc.(*connectivityStateManager).updateState()
      /home/sveatlo/src/go/pkg/mod/google.golang.org/[email protected]/clientconn.go:434 +0x1e8
  google.golang.org/grpc.(*ccBalancerWrapper).UpdateState()
      /home/sveatlo/src/go/pkg/mod/google.golang.org/[email protected]/balancer_conn_wrappers.go:178 +0x15e
  google.golang.org/grpc/balancer/base.(*baseBalancer).ResolverError()
      /home/sveatlo/src/go/pkg/mod/google.golang.org/[email protected]/balancer/base/balancer.go:88 +0x166
  google.golang.org/grpc/balancer/base.(*baseBalancer).UpdateClientConnState()
      /home/sveatlo/src/go/pkg/mod/google.golang.org/[email protected]/balancer/base/balancer.go:155 +0x6e4
  google.golang.org/grpc.(*ccBalancerWrapper).updateClientConnState()
      /home/sveatlo/src/go/pkg/mod/google.golang.org/[email protected]/balancer_conn_wrappers.go:122 +0x182
  google.golang.org/grpc.(*ClientConn).updateResolverState()
      /home/sveatlo/src/go/pkg/mod/google.golang.org/[email protected]/clientconn.go:686 +0x40c
  google.golang.org/grpc.(*ccResolverWrapper).UpdateState()
      /home/sveatlo/src/go/pkg/mod/google.golang.org/[email protected]/resolver_conn_wrapper.go:148 +0x2cd
  github.com/moderntv/cadre/registry.(*registryResolver).updateAddressesFromRegistry()
      /home/sveatlo/src/go/pkg/mod/github.com/moderntv/[email protected]/registry/resolver.go:77 +0x535
  github.com/moderntv/cadre/registry.(*registryResolver).start()
      /home/sveatlo/src/go/pkg/mod/github.com/moderntv/[email protected]/registry/resolver.go:52 +0x55

Previous write at 0x0000017f13c0 by main goroutine:
  google.golang.org/grpc/grpclog.SetLoggerV2()
      /home/sveatlo/src/go/pkg/mod/google.golang.org/[email protected]/grpclog/loggerv2.go:74 +0x42e
  github.com/rkollar/go-grpc-middleware/logging/zerolog.ReplaceGrpcLoggerV2WithVerbosity()
      /home/sveatlo/src/go/pkg/mod/github.com/rkollar/[email protected]/logging/zerolog/grpclogger.go:67 +0x362
  github.com/rkollar/go-grpc-middleware/logging/zerolog.ReplaceGrpcLoggerV2()
      /home/sveatlo/src/go/pkg/mod/github.com/rkollar/[email protected]/logging/zerolog/grpclogger.go:57 +0x7c7
  github.com/moderntv/cadre.(*Builder).buildGrpc()
      /home/sveatlo/src/go/pkg/mod/github.com/moderntv/[email protected]/builder.go:302 +0x74b
  github.com/moderntv/cadre.(*Builder).Build()
      /home/sveatlo/src/go/pkg/mod/github.com/moderntv/[email protected]/builder.go:148 +0xe84
  main.main()
      /home/sveatlo/src/go/src/git.moderntv.eu/mcloud/collector/cmd/gateway/main.go:216 +0x1f0a

Goroutine 31 (running) created at:
  github.com/moderntv/cadre/registry.(*resolverBuilder).Build()
      /home/sveatlo/src/go/pkg/mod/github.com/moderntv/[email protected]/registry/resolver.go:24 +0x1e4
  google.golang.org/grpc.newCCResolverWrapper()
      /home/sveatlo/src/go/pkg/mod/google.golang.org/[email protected]/resolver_conn_wrapper.go:74 +0x457
  google.golang.org/grpc.DialContext()
      /home/sveatlo/src/go/pkg/mod/google.golang.org/[email protected]/clientconn.go:313 +0x11fa
  google.golang.org/grpc.Dial()
      /home/sveatlo/src/go/pkg/mod/google.golang.org/[email protected]/clientconn.go:105 +0x128
  git.moderntv.eu/mcloud/collector/internal/gateway.New()
      /home/sveatlo/src/go/src/git.moderntv.eu/mcloud/collector/internal/gateway/gateway.go:28 +0x5e
  main.main()
      /home/sveatlo/src/go/src/git.moderntv.eu/mcloud/collector/cmd/gateway/main.go:151 +0x14d7
==================

@ builder.go:302 - ReplaceGrpcLoggerV2 should be called before any other grpc function because the underlying function (SetLoggerV2) is not mutex protected (see https://pkg.go.dev/google.golang.org/grpc/grpclog#SetLoggerV2)

@sveatlo
Copy link
Contributor Author

sveatlo commented Jun 24, 2021

@rkollar any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant