Skip to content

Commit

Permalink
Add mutex to control the number of goroutine looking up meta table
Browse files Browse the repository at this point in the history
  • Loading branch information
YutSean committed May 19, 2021
1 parent 3489911 commit b447f9d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ type client struct {
// regionReadTimeout is the maximum amount of time to wait for regionserver reply
regionReadTimeout time.Duration

// The lock to control meta table lookup
lock sync.Mutex

done chan struct{}
closeOnce sync.Once

Expand Down
2 changes: 2 additions & 0 deletions rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,10 @@ func (c *client) metaLookup(ctx context.Context,
return nil, "", err
}

c.lock.Lock()
scanner := c.Scan(rpc)
resp, err := scanner.Next()
c.lock.Unlock()
if err == io.EOF {
return nil, "", TableNotFound
}
Expand Down

0 comments on commit b447f9d

Please sign in to comment.