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

store/tikv: drop the unreachable store's regions from cache. #2792

Merged
merged 5 commits into from
Mar 8, 2017

Conversation

disksing
Copy link
Contributor

@disksing disksing commented Mar 7, 2017

When a store is down and it contains a lot of regions (maybe up to 10k+), tidb will suffer from "connection refused" error for a long time.

cc @AndreMouche @shenli @hhkbp2

@@ -254,6 +254,28 @@ func (s *testRegionCacheSuite) TestRequestFail(c *C) {
c.Assert(region.unreachableStores, HasLen, 0)
}

func (s *testRegionCacheSuite) TestRequestFail2(c *C) {
// ['' - 'm' - 'z']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comments: key range:

c.Assert(err, IsNil)
c.Assert(loc2.Region.id, Equals, region2)

// Request fails on region1.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/fails/should fail/

s.cache.OnRequestFail(ctx)
// Both region2 and store should be dropped from cache.
c.Assert(s.cache.storeMu.stores, HasLen, 0)
c.Assert(s.cache.getRegionFromCache([]byte("x")), IsNil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's hard for me to understand this test case==

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It first splits the cluster to 2 regions (region1, region2) while their leaders are on the same store (store1). After request fails on region1, we check if region2 and store1 are removed from cache.

@AndreMouche
Copy link
Contributor

LGTM

@disksing
Copy link
Contributor Author

disksing commented Mar 8, 2017

PTAL @ngaut

// Both region2 and store should be dropped from cache.
c.Assert(s.cache.storeMu.stores, HasLen, 0)
c.Assert(s.cache.getRegionFromCache([]byte("x")), IsNil)
s.checkCache(c, 1)
Copy link
Member

@coocood coocood Mar 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If only one store is used, why there is still one region in the cache?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

region1 is not removed, we have to try its other peers before reload it from pd, because pd may not be updated in time.

@coocood
Copy link
Member

coocood commented Mar 8, 2017

LGTM

@disksing disksing merged commit 2809d2f into master Mar 8, 2017
@disksing disksing deleted the disksing/request-fail branch March 8, 2017 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants