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

tikvclient: refine region-cache #10256

Merged
merged 28 commits into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
03c6f52
tikvclient: try follower peers when leader unreachable
lysu Apr 25, 2019
33cf201
tikv: blackout region store when send request failure
lysu Apr 30, 2019
4d71d79
address comment and refine
lysu Apr 30, 2019
f8c9e6c
address comment - remove _workStore
lysu May 5, 2019
72befe2
address comment - remove bit operation
lysu May 5, 2019
2247229
ac: resolve fail store's addr in another goroutine
lysu May 6, 2019
da530fb
ac: fix store/peer relationship bug
lysu May 7, 2019
1b915d1
remove unused code.
lysu May 7, 2019
966f350
refine rr balance logic and refine test case
lysu May 7, 2019
d5c2282
refine reload region
lysu May 8, 2019
21a511a
fix locate key
lysu May 8, 2019
c3cb447
refine region epoch not match handle
lysu May 9, 2019
ca2ef1b
notify check store via a channel
lysu May 9, 2019
0311be2
ac: reduce atomic.Load time
lysu May 11, 2019
fc54dde
release region-cache goroutine in testcase
lysu May 13, 2019
438c590
address comments
lysu May 14, 2019
b2a9962
address comments
lysu May 17, 2019
74e084c
address comments
lysu May 17, 2019
7988050
address comments
lysu May 17, 2019
66cfe83
simplify use defer
lysu May 17, 2019
77f5f6e
address comment
lysu May 17, 2019
f74329e
address comment
lysu May 17, 2019
f817653
address comment
lysu May 17, 2019
c34dcbb
address comment
lysu May 17, 2019
7804403
reload region after try 5 peers
lysu May 17, 2019
cbfd25e
address comment
lysu May 20, 2019
6e9f6f4
NotLeader's leader maybe miss in current cache
lysu May 20, 2019
94794bb
Merge branch 'master' into dev-region-retry-fail
tiancaiamao May 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ddl/table_split_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func checkRegionStartWithTableID(c *C, id int64, store kvStore) {
c.Assert(err, IsNil)

// Region cache may be out of date, so we need to drop this expired region and load it again.
cache.DropRegion(loc.Region)
cache.InvalidateCachedRegion(loc.Region)
if bytes.Equal(loc.StartKey, []byte(regionStartKey)) {
return
}
Expand Down
5 changes: 4 additions & 1 deletion store/tikv/coprocessor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func (s *testCoprocessorSuite) TestBuildTasks(c *C) {
_, regionIDs, _ := mocktikv.BootstrapWithMultiRegions(cluster, []byte("g"), []byte("n"), []byte("t"))
pdCli := &codecPDClient{mocktikv.NewPDClient(cluster)}
cache := NewRegionCache(pdCli)
defer cache.Close()

bo := NewBackoffer(context.Background(), 3000)

Expand Down Expand Up @@ -96,6 +97,7 @@ func (s *testCoprocessorSuite) TestSplitRegionRanges(c *C) {
mocktikv.BootstrapWithMultiRegions(cluster, []byte("g"), []byte("n"), []byte("t"))
pdCli := &codecPDClient{mocktikv.NewPDClient(cluster)}
cache := NewRegionCache(pdCli)
defer cache.Close()

bo := NewBackoffer(context.Background(), 3000)

Expand Down Expand Up @@ -148,6 +150,7 @@ func (s *testCoprocessorSuite) TestRebuild(c *C) {
storeID, regionIDs, peerIDs := mocktikv.BootstrapWithMultiRegions(cluster, []byte("m"))
pdCli := &codecPDClient{mocktikv.NewPDClient(cluster)}
cache := NewRegionCache(pdCli)
defer cache.Close()
bo := NewBackoffer(context.Background(), 3000)

tasks, err := buildCopTasks(bo, cache, buildCopRanges("a", "z"), false, false)
Expand All @@ -161,7 +164,7 @@ func (s *testCoprocessorSuite) TestRebuild(c *C) {
regionIDs = append(regionIDs, cluster.AllocID())
peerIDs = append(peerIDs, cluster.AllocID())
cluster.Split(regionIDs[1], regionIDs[2], []byte("q"), []uint64{peerIDs[2]}, storeID)
cache.DropRegion(tasks[1].region)
cache.InvalidateCachedRegion(tasks[1].region)

tasks, err = buildCopTasks(bo, cache, buildCopRanges("a", "z"), true, false)
c.Assert(err, IsNil)
Expand Down
1 change: 1 addition & 0 deletions store/tikv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ func (s *tikvStore) Close() error {
if s.txnLatches != nil {
s.txnLatches.Close()
}
s.regionCache.Close()
return nil
}

Expand Down
10 changes: 9 additions & 1 deletion store/tikv/rawkv.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,15 @@ func NewRawKVClient(pdAddrs []string, security config.Security) (*RawKVClient, e

// Close closes the client.
func (c *RawKVClient) Close() error {
c.pdClient.Close()
if c.pdClient != nil {
c.pdClient.Close()
}
if c.regionCache != nil {
c.regionCache.Close()
}
if c.rpcClient == nil {
return nil
}
return c.rpcClient.Close()
}

Expand Down
Loading