Browse Source

clientv3: Fix concurrent clientv3 client creation in 3.4 by using proper UUIDs

Joe Betz 7 years ago
parent
commit
6a43db1eff
1 changed files with 3 additions and 1 deletions
  1. 3 1
      clientv3/client.go

+ 3 - 1
clientv3/client.go

@@ -27,6 +27,8 @@ import (
 	"sync"
 	"time"
 
+	"github.com/google/uuid"
+
 	"github.com/grpc-ecosystem/go-grpc-middleware/util/backoffutils"
 	"go.etcd.io/etcd/clientv3/balancer"
 	"go.etcd.io/etcd/clientv3/balancer/picker"
@@ -477,7 +479,7 @@ func newClient(cfg *Config) (*Client, error) {
 
 	// Prepare a 'endpoint://<unique-client-id>/' resolver for the client and create a endpoint target to pass
 	// to dial so the client knows to use this resolver.
-	client.resolverGroup, err = endpoint.NewResolverGroup(fmt.Sprintf("client-%s", strconv.FormatInt(time.Now().UnixNano(), 36)))
+	client.resolverGroup, err = endpoint.NewResolverGroup(fmt.Sprintf("client-%s", uuid.New().String()))
 	if err != nil {
 		client.cancel()
 		return nil, err