Skip to content

Commit 80558c5

Browse files
committed
[FAB-10714] fix data race on grpc.EnableTracing
Setting the global variable inside of a connection factory does not provide any guarantees that some other component in the process has not already created and/or established gRPC sessions. This has resulted in data races in the tests. Moving the code to the peer initialization where it should be safer to set. Change-Id: Ifa6c87c88d1336ceea72755db85de19774ba8082 Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
1 parent b7fbc81 commit 80558c5

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

core/deliverservice/deliveryclient.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ func DefaultConnectionFactory(channelID string) func(endpoint string) (*grpc.Cli
262262
} else {
263263
dialOpts = append(dialOpts, grpc.WithInsecure())
264264
}
265-
grpc.EnableTracing = true
266265
ctx := context.Background()
267266
ctx, _ = context.WithTimeout(ctx, getConnectionTimeout())
268267
return grpc.DialContext(ctx, endpoint, dialOpts...)

peer/node/start.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ func serve(args []string) error {
134134
}
135135
}
136136

137+
// Trace RPCs with the golang.org/x/net/trace package. This was moved out of
138+
// the deliver service connection factory as it has process wide implications
139+
// and was racy with respect to initialization of gRPC clients and servers.
140+
grpc.EnableTracing = true
141+
137142
flogging.SetPeerStartupModulesMap()
138143

139144
logger.Infof("Starting %s", version.GetInfo())

0 commit comments

Comments
 (0)