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

*: check region epoch strictly #4125

Merged
merged 14 commits into from
Feb 1, 2019
Merged

Conversation

overvenus
Copy link
Member

@overvenus overvenus commented Jan 25, 2019

What have you changed?

Checks region epoch strictly to avoid KeyNotInRegion errors.

A 3 nodes TiKV cluster with merge enabled, after commit merge, TiKV A
tells TiDB with a epoch not match error contains the latest target Region
info, TiDB updates its region cache and sends requests to TiKV B,
and TiKV B has not applied commit merge yet, since the region epoch in
request is higher than TiKV B, the request must be denied due to epoch
not match, so it does not read on a stale snapshot, thus avoid the
KeyNotInRegion error.

What are the type of the changes? (mandatory)

  • Bug fix (non-breaking change which fixes an issue)

How has this PR been tested? (mandatory)

Integrations tests

Does this PR affect documentation (docs) update? (mandatory)

No

Does this PR affect tidb-ansible update? (mandatory)

No

Cc pingcap/kvproto#344

Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
@overvenus overvenus added sig/raft Component: Raft, RaftStore, etc. type/bugfix This PR fixes a bug. labels Jan 25, 2019
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
@overvenus overvenus removed the S: WIP label Jan 25, 2019
src/storage/mod.rs Outdated Show resolved Hide resolved
Signed-off-by: Neil Shen <overvenus@gmail.com>
@zhangjinpeng87
Copy link
Member

Please fix conflicts

@Connor1996
Copy link
Member

Connor1996 commented Jan 28, 2019

Please refer to the related kvproto PR

Copy link
Member

@Connor1996 Connor1996 left a comment

Choose a reason for hiding this comment

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

most LGTM. Seems that we should reproduce the issue in test

@overvenus
Copy link
Member Author

@Connor1996 It is reproduced in test_split_epoch_not_match.

@MyonKeminta
Copy link
Contributor

/release

@sre-bot
Copy link
Contributor

sre-bot commented Jan 29, 2019

@overvenus
Copy link
Member Author

PTAL, thanks!

@siddontang
Copy link
Contributor

any update about this and corresponding other PRs?

@overvenus @MyonKeminta

Signed-off-by: Neil Shen <overvenus@gmail.com>
@overvenus
Copy link
Member Author

/run-integration-tests tidb=release-2.1 pd=release-2.1 tidb-test=release-2.1

Copy link
Member

@zhangjinpeng87 zhangjinpeng87 left a comment

Choose a reason for hiding this comment

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

LGTM

@MyonKeminta
Copy link
Contributor

/release

@sre-bot
Copy link
Contributor

sre-bot commented Jan 31, 2019

@BusyJay
Copy link
Member

BusyJay commented Feb 1, 2019

There seems to be no case about the situation you describe.

Copy link
Member

@Connor1996 Connor1996 left a comment

Choose a reason for hiding this comment

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

LGTM

@overvenus overvenus merged commit f54fd4f into tikv:master Feb 1, 2019
@overvenus overvenus deleted the epoch-not-match branch February 1, 2019 07:43
@overvenus
Copy link
Member Author

overvenus commented Feb 3, 2019

There is a test case covers the situation https://github.com/tikv/tikv/pull/4125/files#diff-87d8831b47ad20a68a88901c547ce300R628. It sends a requests with a newer epoch and get a key which is out of the region. @BusyJay

overvenus added a commit to overvenus/tikv that referenced this pull request Feb 26, 2019
Checks region epoch strictly to avoid KeyNotInRegion errors.

A 3 nodes TiKV cluster with merge enabled, after commit merge, TiKV A
tells TiDB with a epoch not match error contains the latest target Region
info, TiDB updates its region cache and sends requests to TiKV B,
and TiKV B has not applied commit merge yet, since the region epoch in
request is higher than TiKV B, the request must be denied due to epoch
not match, so it does not read on a stale snapshot, thus avoid the
KeyNotInRegion error.

Signed-off-by: Neil Shen <overvenus@gmail.com>
sticnarf pushed a commit to sticnarf/tikv that referenced this pull request Oct 27, 2019
Checks region epoch strictly to avoid KeyNotInRegion errors.

A 3 nodes TiKV cluster with merge enabled, after commit merge, TiKV A
tells TiDB with a epoch not match error contains the latest target Region
info, TiDB updates its region cache and sends requests to TiKV B,
and TiKV B has not applied commit merge yet, since the region epoch in
request is higher than TiKV B, the request must be denied due to epoch
not match, so it does not read on a stale snapshot, thus avoid the
KeyNotInRegion error.

Signed-off-by: Neil Shen <overvenus@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/raft Component: Raft, RaftStore, etc. type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants