Tpstorage TiKV从scheduler是怎么发消息到raftstore

追prewrite到了stc/storage/mvcc/txn.rs的put_lock

    pub(crate) fn put_lock(&mut self, key: Key, lock: &Lock) {
        let write = Modify::Put(CF_LOCK, key, lock.to_bytes());
        self.write_size += write.size();
        self.modifies.push(write);
    }

这里只是把key/value信息组织好,放入self.modifies里面.
那么什么时候self.modifies的内容会发给raftstore去处理呢?没找到发送的地方。麻烦大神们指点下。谢谢。请精确到确切的行数吧,谢谢。目前我看的是5.4的代码。

  1. Scheduler::process_write, https://github.com/tikv/tikv/blob/v5.4.0/src/storage/txn/scheduler.rs#L728
  2. task.cmd.process_write, https://github.com/tikv/tikv/blob/v5.4.0/src/storage/txn/scheduler.rs#L750. 这里会走到 put_lock
  3. engine::async_write_ext, https://github.com/tikv/tikv/blob/v5.4.0/src/storage/txn/scheduler.rs#L990
  4. RaftKv::async_write_ext, https://github.com/tikv/tikv/blob/v5.4.0/src/server/raftkv.rs#L373
  5. self.router.send_command(cmd, cb, extra_opts)?; https://github.com/tikv/tikv/blob/v5.4.0/src/server/raftkv.rs#L281. 这里就走到 raftstore 了
1 Like

感谢回复,回复的非常清楚,谢谢

我也翻到了,scheduler.rs这里会调用raftengine的async_write_ext发送消息到batch_system。