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

support follower read #5051

Merged
merged 14 commits into from
Jul 17, 2019
Merged

support follower read #5051

merged 14 commits into from
Jul 17, 2019

Conversation

5kbpers
Copy link
Member

@5kbpers 5kbpers commented Jul 9, 2019

Signed-off-by: 5kbpers [email protected]

What have you changed? (mandatory)

This PR introduces a new feature, which enables clients to read data from follower peers.
We add a new RPC option follower_read to struct Context within every request, see 5kbpers/kvproto@e55978c

What are the type of the changes? (mandatory)

  • New feature (change which adds functionality)

How has this PR been tested? (mandatory)

integration tests

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

No.

Refer to a related PR or issue link (optional)

pingcap/kvproto#424

@5kbpers
Copy link
Member Author

5kbpers commented Jul 9, 2019

/run-all-tests

src/raftstore/store/peer.rs Outdated Show resolved Hide resolved
src/raftstore/store/peer.rs Outdated Show resolved Hide resolved
src/raftstore/store/peer.rs Outdated Show resolved Hide resolved
src/raftstore/store/peer.rs Show resolved Hide resolved
src/raftstore/store/peer.rs Outdated Show resolved Hide resolved
src/raftstore/store/peer.rs Outdated Show resolved Hide resolved
tests/failpoints/cases/test_follower_read.rs Show resolved Hide resolved
tests/failpoints/cases/test_follower_read.rs Outdated Show resolved Hide resolved
5kbpers added 2 commits July 11, 2019 11:10
Signed-off-by: 5kbpers <[email protected]>
Signed-off-by: 5kbpers <[email protected]>
5kbpers added 2 commits July 11, 2019 15:44
Signed-off-by: 5kbpers <[email protected]>
overvenus
overvenus previously approved these changes Jul 11, 2019
Copy link
Member

@overvenus overvenus left a comment

Choose a reason for hiding this comment

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

Rest LGTM

cluster.must_transfer_leader(region.get_id(), p2.clone());

// Block all write cmd applying of Peer 3.
fail::cfg("on_apply_write_cmd", "sleep(5000)").unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

How about pause? It works like sleep but blocks forever until turning it off.

Copy link
Member Author

Choose a reason for hiding this comment

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

The apply thread could not exit after the assertion failed (before the fail point was turned off) if we use pause.

tests/failpoints/cases/test_follower_read.rs Outdated Show resolved Hide resolved
@5kbpers 5kbpers changed the title [DNM] support follower read support follower read Jul 11, 2019
Cargo.toml Outdated Show resolved Hide resolved
@breezewish breezewish added the sig/raft Component: Raft, RaftStore, etc. label Jul 15, 2019
Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

LGTM

@5kbpers
Copy link
Member Author

5kbpers commented Jul 17, 2019

/run-all-tests

@5kbpers 5kbpers merged commit 118f141 into tikv:master Jul 17, 2019
sticnarf pushed a commit to sticnarf/tikv that referenced this pull request Oct 27, 2019
* raftstore,server: support follower read

Signed-off-by: 5kbpers <[email protected]>

* raftstore: fix condition check of read on replica

Signed-off-by: 5kbpers <[email protected]>

* raftstore: follower read waits for apply index reaches read index

Signed-off-by: 5kbpers <[email protected]>

* add a test of waiting for read index

Signed-off-by: 5kbpers <[email protected]>

* fix test_wait_for_apply_index

Signed-off-by: 5kbpers <[email protected]>

* dec pending reads count after follower handle read index cmd

Signed-off-by: 5kbpers <[email protected]>

* update comments

Signed-off-by: 5kbpers <[email protected]>

* remove unused file

Signed-off-by: 5kbpers <[email protected]>

* fix test_wait_for_apply_index

Signed-off-by: 5kbpers <[email protected]>

* update comments

Signed-off-by: 5kbpers <[email protected]>

* update test_wait_for_apply_index

Signed-off-by: 5kbpers <[email protected]>

* update dependency 'kvproto'

Signed-off-by: 5kbpers <[email protected]>
fredchenbj pushed a commit to fredchenbj/tikv that referenced this pull request Mar 10, 2020
* raftstore,server: support follower read
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants