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

tikv: make region request can send to flash store #11652

Merged
merged 18 commits into from
Sep 25, 2019

Conversation

lzmhhh123
Copy link
Contributor

What problem does this PR solve?

Make region request can send to flash store.

What is changed and how it works?

Add global config to reveal tiflash store labels and some flash mark in tikv.Store.

Check List

Tests

  • Unit test
  • Integration test

Code changes

  • Has exported function/method change
  • Has exported variable/fields change
  • Has persistent data change

Side effects

  • Possible performance regression
  • Increased code complexity

Related changes

  • None

@codecov
Copy link

codecov bot commented Aug 7, 2019

Codecov Report

Merging #11652 into master will increase coverage by 0.2002%.
The diff coverage is 34.4537%.

@@               Coverage Diff                @@
##             master     #11652        +/-   ##
================================================
+ Coverage   80.9013%   81.1015%   +0.2002%     
================================================
  Files           454        454                
  Lines        100138      98405      -1733     
================================================
- Hits          81013      79808      -1205     
+ Misses        13319      12847       -472     
+ Partials       5806       5750        -56

Copy link
Contributor

@lysu lysu left a comment

Choose a reason for hiding this comment

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

maybe need take care #11347...

and take care fail retry logic:

  • kv request fail should not switch and try to flash node
  • flash request fail's retry should not switch to kv node(it seem current code works for this item :D)
  • does tiflush has some return error logic like onRegionError?

store/tikv/region_request.go Outdated Show resolved Hide resolved
@lysu lysu requested a review from coocood August 8, 2019 03:27
@lzmhhh123
Copy link
Contributor Author

@lysu
answer for three suggestion:

  1. OK.
  2. Yes, that's my fault.
  3. RegionErr return must keep same with tikv. I'll confirm this with tiflash team.

config/config.go Outdated Show resolved Hide resolved
@coocood
Copy link
Member

coocood commented Aug 9, 2019

@lzmhhh123
Seems the logic conflicts with this PR
#11347

config/config_test.go Outdated Show resolved Hide resolved
@lzmhhh123
Copy link
Contributor Author

@lysu @coocood @zz-jason Because of some reasons that the hint to access flash doesn't toward the agreement with PM team. This PR needn't merge to master now. After testing with the flash team, I will consider the situation with follower read.

@lzmhhh123 lzmhhh123 closed this Aug 9, 2019
@lzmhhh123 lzmhhh123 removed the priority/P1 The issue has P1 priority. label Aug 19, 2019
@lzmhhh123 lzmhhh123 reopened this Aug 19, 2019
@lzmhhh123
Copy link
Contributor Author

It's ready for review.

store/tikv/region_cache.go Show resolved Hide resolved
store/tikv/region_cache.go Outdated Show resolved Hide resolved
store/tikv/region_cache.go Outdated Show resolved Hide resolved
store/tikv/region_cache.go Outdated Show resolved Hide resolved
store/tikv/region_cache.go Outdated Show resolved Hide resolved
store/tikv/region_request.go Outdated Show resolved Hide resolved
store/tikv/region_cache.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/config.go Outdated Show resolved Hide resolved
config/config_test.go Outdated Show resolved Hide resolved
store/tikv/region_request.go Outdated Show resolved Hide resolved
store/tikv/region_request.go Outdated Show resolved Hide resolved
store/tikv/coprocessor.go Show resolved Hide resolved
store/tikv/region_cache.go Outdated Show resolved Hide resolved
@lzmhhh123 lzmhhh123 force-pushed the dev/add_theflash_access_flag branch 3 times, most recently from 82f1f8c to 598f889 Compare August 23, 2019 03:43
@lzmhhh123 lzmhhh123 requested review from SunRunAway and removed request for SunRunAway September 23, 2019 05:16
Copy link
Contributor

@lysu lysu left a comment

Choose a reason for hiding this comment

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

at last, maybe we should take care switchNextPeer

func (c *RegionCache) switchNextPeer(r *Region, currentPeerIdx int, err error) {

this method will be called after send request failure

if e := s.onSendFail(bo, ctx, err); e != nil {

A request to TiKV leader should not switch current work index to TiFish, if so maybe will lead write request to send to TiFlash.

and A req to TiFlash maybe better not trigger "switch current work"(e.g. one TiFlash node has crashed, but TiKV's leader is work well and keep handling oltp load).

s.storeType = TiKV
for _, label := range store.Labels {
if label.Key == "engine" && label.Value == "tiflash" {
s.storeType = TiFlash
Copy link
Contributor

Choose a reason for hiding this comment

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

we can break when label.Key == "engine" even if label.Value != "tiflash"

storeType := TiKV
for _, label := range store.Labels {
if label.Key == "engine" && label.Value == "tiflash" {
storeType = TiFlash
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

regionStore := cachedRegion.getStore()

tikvCnt := 0
for i, store := range regionStore.stores {
Copy link
Contributor

@lysu lysu Sep 24, 2019

Choose a reason for hiding this comment

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

Do we have the situation that 1 region have multiple TiFlash?

if so we should take care failure in one of TiFlash store and loadbalance between multiple TiFlash node.

for example, region1 has 3 TiFlash node: a, b, c.

we should give chance to use b and c; and send request to b and c when a is failured?

@lysu lysu added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Sep 24, 2019
lysu
lysu previously approved these changes Sep 24, 2019
Copy link
Contributor

@lysu lysu left a comment

Choose a reason for hiding this comment

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

LGTM

store/tikv/region_cache.go Outdated Show resolved Hide resolved
store/tikv/region_cache.go Outdated Show resolved Hide resolved
@lzmhhh123 lzmhhh123 requested a review from lysu September 25, 2019 02:46
Copy link
Contributor

@lysu lysu left a comment

Choose a reason for hiding this comment

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

LGTM

@lzmhhh123 lzmhhh123 added the status/can-merge Indicates a PR has been approved by a committer. label Sep 25, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Sep 25, 2019

/run-all-tests

@sre-bot sre-bot merged commit b25b703 into pingcap:master Sep 25, 2019
@lzmhhh123 lzmhhh123 deleted the dev/add_theflash_access_flag branch September 25, 2019 03:00
lzmhhh123 added a commit to lzmhhh123/tidb that referenced this pull request Jan 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/server component/tikv status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/new-feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants