Skip to content

Commit b096da3

Browse files
committed
fix race on cluster close
1 parent 45296b6 commit b096da3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

internal/cluster/cluster.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ func (c *cluster) Get(ctx context.Context) (cc conn.Conn, err error) {
252252
ctx, cancel = context.WithTimeout(ctx, MaxGetConnTimeout)
253253
defer cancel()
254254

255+
c.mu.RLock()
256+
defer c.mu.RUnlock()
257+
255258
if c.closed {
256259
return nil, errors.WithStackTrace(ErrClusterClosed)
257260
}
@@ -266,9 +269,7 @@ func (c *cluster) Get(ctx context.Context) (cc conn.Conn, err error) {
266269
}()
267270

268271
if e, ok := ContextEndpoint(ctx); ok {
269-
c.mu.RLock()
270272
cc, ok = c.endpoints[e.NodeID()]
271-
c.mu.RUnlock()
272273
if ok && cc.IsState(
273274
conn.Created,
274275
conn.Online,

trace/driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func (m Method) Service() (s string) {
7676
return
7777
}
7878

79-
// Issue interface
79+
// Issue declare interface of operation error issues
8080
type Issue interface {
8181
GetMessage() string
8282
GetIssueCode() uint32

0 commit comments

Comments
 (0)