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

coprocessor: split ranges if the slice is too big #7454

Merged
merged 4 commits into from
Aug 23, 2018

Conversation

winoros
Copy link
Member

@winoros winoros commented Aug 21, 2018

What problem does this PR solve?

This PR aims to solve the issue that the TiKV timeout error is caused by the too large range in one request.

What is changed and how it works?

According to @coocood 's advice, split the range in one region when building copTask. So we won't send a message that is too large.

Check List

Tests

  • Existing tests.
  • Manual test, select count(*) from t where key in (800k constant list).

@winoros winoros added type/enhancement The issue or PR belongs to an enhancement. component/coprocessor labels Aug 21, 2018
cmdType: cmdType,
})
rLen := ranges.len()
for i := 0; i < rLen; {
Copy link
Member

Choose a reason for hiding this comment

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

Need to add comments about why slice the task by range.

@coocood
Copy link
Member

coocood commented Aug 22, 2018

/run-all-tests

@@ -235,6 +236,8 @@ func (r *copRanges) split(key []byte) (*copRanges, *copRanges) {
return r.slice(0, n), r.slice(n, r.len())
}

const rangesPerTask = 25000
Copy link
Member

Choose a reason for hiding this comment

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

Better to add some comment about what this value is used to do, why need it, why set it to this value.

respChan: make(chan *copResponse, 1),
cmdType: cmdType,
})
// etcd will return error if the message is too large. So we need to limit the length of the ranges slice
Copy link
Member

Choose a reason for hiding this comment

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

tikv will return gRPC error

Copy link
Contributor

@zimulala zimulala left a comment

Choose a reason for hiding this comment

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

LGTM

@zimulala zimulala added the status/LGT1 Indicates that a PR has LGTM 1. label Aug 22, 2018
@coocood
Copy link
Member

coocood commented Aug 22, 2018

LGTM

@coocood coocood added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Aug 22, 2018
@coocood coocood merged commit ef6590e into pingcap:master Aug 23, 2018
@winoros winoros deleted the split-range branch September 5, 2018 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/coprocessor status/LGT2 Indicates that a PR has LGTM 2. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants