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

Remove stale-read flag after resolving lock #792

Merged
merged 9 commits into from
May 26, 2023

Conversation

you06
Copy link
Contributor

@you06 you06 commented May 9, 2023

Ref pingcap/tidb#43659

Remove the stale-read flag after resolving lock.

Before this PR:

before

After this PR:

after

Because the request struct is reused when retrying in get, it'll suffer not leader error, because the stale read field is already reset from the context patcher. But the request is regenerated in batch get, so it'll meet data is not ready instead. For both cases, this PR reduces unnecessary RPC.

you06 added 6 commits May 6, 2023 11:51
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
@@ -275,6 +275,12 @@ func (req *Request) EnableStaleRead() {
req.ReplicaRead = false
}

// DisableStaleRead is called when stale-read fallbacks to leader read after meeting key-is-locked error.
func (req *Request) DisableStaleRead() {
Copy link
Contributor

Choose a reason for hiding this comment

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

How about DisableStaleReadAfterFallback

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rename it with DisableStaleReadMeetLock because it should only take effect when key is locked, other rollback won't affect this flag

@cfzjywxk cfzjywxk requested a review from zyguan May 25, 2023 13:19
you06 added 2 commits May 26, 2023 11:53
Signed-off-by: you06 <you1474600@gmail.com>
@cfzjywxk
Copy link
Contributor

/test

Signed-off-by: you06 <you1474600@gmail.com>
@cfzjywxk cfzjywxk merged commit 11121c6 into tikv:master May 26, 2023
you06 added a commit to you06/client-go that referenced this pull request May 26, 2023
* remove stale-read when key-is-locked

Signed-off-by: you06 <you1474600@gmail.com>

* disable follower read for batch get

Signed-off-by: you06 <you1474600@gmail.com>

* the stale-read flag may already set to false

Signed-off-by: you06 <you1474600@gmail.com>

* fix batchget

Signed-off-by: you06 <you1474600@gmail.com>

* Reset busy-threshold when stale read fallback to leader read

Signed-off-by: you06 <you1474600@gmail.com>

* address comment

Signed-off-by: you06 <you1474600@gmail.com>

* trigger CI

Signed-off-by: you06 <you1474600@gmail.com>

---------

Signed-off-by: you06 <you1474600@gmail.com>
cfzjywxk pushed a commit that referenced this pull request May 29, 2023
* add metrics for stale-read traffic (#776)

Signed-off-by: you06 <you1474600@gmail.com>

* Remove stale-read flag after resolving lock (#792)

* remove stale-read when key-is-locked

Signed-off-by: you06 <you1474600@gmail.com>

* disable follower read for batch get

Signed-off-by: you06 <you1474600@gmail.com>

* the stale-read flag may already set to false

Signed-off-by: you06 <you1474600@gmail.com>

* fix batchget

Signed-off-by: you06 <you1474600@gmail.com>

* Reset busy-threshold when stale read fallback to leader read

Signed-off-by: you06 <you1474600@gmail.com>

* address comment

Signed-off-by: you06 <you1474600@gmail.com>

* trigger CI

Signed-off-by: you06 <you1474600@gmail.com>

---------

Signed-off-by: you06 <you1474600@gmail.com>

---------

Signed-off-by: you06 <you1474600@gmail.com>
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.

3 participants