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

server: direct send raft message to grpc client. #1882

Merged
merged 39 commits into from
Jun 22, 2017
Merged

Conversation

disksing
Copy link
Contributor

@disksing disksing commented Jun 2, 2017

No description provided.

@disksing disksing requested review from siddontang and BusyJay June 2, 2017 00:07
if !msg.get_message().has_snapshot() {
let addr = self.raft_client.rl().addrs.get(&to_store_id).map(|x| x.to_owned());
if let Some(addr) = addr {
if let Err(e) = self.raft_client.wl().send(to_store_id, addr.to_owned(), msg) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why to_owned twice?

Copy link
Contributor

Choose a reason for hiding this comment

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

should consider the case of address outdated if the remote store changes its address, although this may be a rare case.

Or if we can't connect remote store many times, do we need to get the address from PD again?

Copy link
Contributor Author

@disksing disksing Jun 2, 2017

Choose a reason for hiding this comment

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

why to_owned twice?

Mistake.

should consider the case of address outdated if the remote store changes its address, although this may be a rare case.

When fail to send a message, the cached address will be removed, then it will be resolved again when next message comes.

@siddontang
Copy link
Contributor

LGTM

PTAL @BusyJay

@BusyJay
Copy link
Member

BusyJay commented Jun 2, 2017

If addresses is stored as rwlock in sender, mio loop can be removed.

@siddontang siddontang added the RC3 label Jun 2, 2017
@@ -636,6 +636,11 @@ impl<T: Transport, C: PdClient> Store<T, C> {
}

fn on_raft_message(&mut self, mut msg: RaftMessage) -> Result<()> {
let store_id = msg.get_to_peer().get_store_id();
Copy link
Contributor

Choose a reason for hiding this comment

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

following is_raft_msg_valid already checks this, and here return this error makes no sense, we will only log this error outside.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, I'll remove it.

@siddontang
Copy link
Contributor

Great work 👍

@siddontang
Copy link
Contributor

PTAL @BusyJay

Ok(())
fn send_store(&self, store_id: u64, msg: RaftMessage) {
// check the corresponding token for store.
let addr = self.raft_client.rl().addrs.get(&store_id).map(|x| x.to_owned());
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use get().cloned() directly?

rocksdb_util::CFOptions::new(CF_RAFT,
get_rocksdb_raftlog_cf_option(config, total_mem))];
let mut db_path = path.clone();
db_path.push("db");
Copy link
Contributor

Choose a reason for hiding this comment

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

kind of strange usage.

let top_dir = Path::new(&cfg.storage.path);
let lock_path = top_dir.join("LOCK");
...
let db_dir = top_dir.join("db");
...

Copy link
Contributor

Choose a reason for hiding this comment

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

also snap_dir, or to say snap_path

@siddontang
Copy link
Contributor

any update? @disksing

disksing added 4 commits June 14, 2017 14:50
# Conflicts:
#	etc/config-template.toml
#	src/bin/tikv-server.rs
#	src/server/config.rs
#	src/server/raft_client.rs
#	src/server/server.rs
#	tests/raftstore/server.rs
@siddontang
Copy link
Contributor

please fix the conflict and merge to master, not grpc branch.

@disksing disksing changed the base branch from grpc to master June 15, 2017 08:24
@@ -81,14 +78,13 @@ impl RaftStoreRouter for ServerRaftStoreRouter {
}

fn send_raft_msg(&self, msg: RaftMessage) -> RaftStoreResult<()> {
let store_id = msg.get_to_peer().get_store_id();
try!(self.validate_store_id(store_id));
if msg.get_region_id() == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

need to check in grpc_service.rs? So we don't add the counter in metric.

let addr = try!(SocketAddr::from_str(&cfg.addr));
let ip = format!("{}", addr.ip());
let channel_args = ChannelBuilder::new(env.clone())
.stream_initial_window_size(cfg.grpc_stream_initial_window_size)
Copy link
Member

Choose a reason for hiding this comment

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

Why delete it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mistake.

@disksing
Copy link
Contributor Author

PTAL @BusyJay @siddontang

@disksing disksing changed the title server: direct send raft message to grpc client (in most cases). server: direct send raft message to grpc client. Jun 21, 2017
Copy link
Contributor

@siddontang siddontang left a comment

Choose a reason for hiding this comment

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

LGTM

@BusyJay
Copy link
Member

BusyJay commented Jun 22, 2017

LGTM

@disksing disksing merged commit 5c68940 into master Jun 22, 2017
@disksing disksing deleted the disksing/raft-msg branch June 22, 2017 08:26
iosmanthus pushed a commit to iosmanthus/tikv that referenced this pull request Oct 17, 2024
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.

5 participants