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

cdc: check leadership before subscribing #6691

Merged
merged 17 commits into from
Mar 2, 2020
Merged

Conversation

5kbpers
Copy link
Member

@5kbpers 5kbpers commented Feb 25, 2020

Signed-off-by: 5kbpers tangminghua@pingcap.com

What have you changed?

Add CasualMessage::CaptureChange for checking leadership before starting to subscribe changes of a region.

What is the type of the changes?

  • Bugfix (a change which fixes an issue)

How is the PR tested?

  • Integration test

Does this PR affect documentation (docs) or should it be mentioned in the release notes?

No.

Does this PR affect tidb-ansible?

No.

5kbpers and others added 4 commits February 25, 2020 17:23
@@ -101,6 +101,7 @@ impl fmt::Debug for Task {
}

pub struct Endpoint {
// TODO: add RaftRouter here.
Copy link
Member

Choose a reason for hiding this comment

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

Can we add it now?

Signed-off-by: 5kbpers <tangminghua@pingcap.com>
@5kbpers 5kbpers added the component/CDC Component: Change Data Capture label Feb 26, 2020
5kbpers and others added 6 commits February 26, 2020 18:02
Signed-off-by: 5kbpers <tangminghua@pingcap.com>
Signed-off-by: 5kbpers <tangminghua@pingcap.com>
Signed-off-by: 5kbpers <tangminghua@pingcap.com>
Signed-off-by: 5kbpers <tangminghua@pingcap.com>
Signed-off-by: 5kbpers <tangminghua@pingcap.com>
@5kbpers
Copy link
Member Author

5kbpers commented Feb 26, 2020

I will submit another PR for reorganizing the tests of cdc after this one is landed.

5kbpers and others added 2 commits February 27, 2020 10:31
Signed-off-by: 5kbpers <tangminghua@pingcap.com>
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

capture_regions: HashMap<u64, Delegate>,
scheduler: Scheduler<Task>,
apply_router: ApplyRouter,
casual_router: T,
Copy link
Member

Choose a reason for hiding this comment

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

Could you name it to raft_router? casual_router sounds confusing.

@@ -257,6 +269,11 @@ impl Endpoint {
fn on_region_ready(&mut self, region_id: u64, resolver: Resolver, region: Region) {
if let Some(delegate) = self.capture_regions.get_mut(&region_id) {
delegate.on_region_ready(resolver, region);
println!("region ready: has_failed({})", delegate.has_failed());
Copy link
Member

Choose a reason for hiding this comment

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

Please remove this line.

cb: Callback::Read(Box::new(move |resp: ReadResponse<_>| {
}
};
if let Err(e) = self.casual_router.send(
Copy link
Member

Choose a reason for hiding this comment

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

Could you log the error?

Signed-off-by: 5kbpers <tangminghua@pingcap.com>
Signed-off-by: 5kbpers <tangminghua@pingcap.com>
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.

LGTM

Copy link
Contributor

@MyonKeminta MyonKeminta 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

}
self.ctx
.apply_router
.schedule_task(self.region_id(), ApplyTask::Change { cmd, cb })
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible that the leader changes after this but before the cmd is executed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but role change events will be caught by the cdc observer.

Copy link
Contributor

@MyonKeminta MyonKeminta 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 5kbpers added the status/can-merge Status: Can merge to base branch label Mar 2, 2020
@sre-bot
Copy link
Contributor

sre-bot commented Mar 2, 2020

/run-all-tests

zhangjinpeng87 pushed a commit to zhangjinpeng87/tikv that referenced this pull request Mar 26, 2020
Signed-off-by: 5kbpers <tangminghua@pingcap.com>
c1ay pushed a commit to c1ay/tikv that referenced this pull request May 9, 2020
Signed-off-by: 5kbpers <tangminghua@pingcap.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/CDC Component: Change Data Capture status/can-merge Status: Can merge to base branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants