MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / phase1_base_copy

Function phase1_base_copy

nodedb-cluster/src/migration_executor/phases.rs:16–94  ·  view source on GitHub ↗
(
    ex: &MigrationExecutor,
    state: &mut MigrationState,
    group_id: u64,
    req: &MigrationRequest,
    migration_id: MigrationId,
)

Source from the content-addressed store, hash-verified

14use super::executor::{MigrationExecutor, MigrationRequest};
15
16pub(super) async fn phase1_base_copy(
17 ex: &MigrationExecutor,
18 state: &mut MigrationState,
19 group_id: u64,
20 req: &MigrationRequest,
21 migration_id: MigrationId,
22) -> Result<()> {
23 let committed = {
24 let mr = ex.multi_raft.lock().unwrap_or_else(|p| p.into_inner());
25 mr.group_statuses()
26 .iter()
27 .find(|s| s.group_id == group_id)
28 .map(|s| s.commit_index)
29 .unwrap_or(0)
30 };
31 state.start_base_copy(committed);
32
33 ex.propose_checkpoint(
34 migration_id,
35 0,
36 MigrationCheckpointPayload::AddLearner {
37 vshard_id: req.vshard_id,
38 source_node: req.source_node,
39 target_node: req.target_node,
40 source_group: group_id,
41 write_pause_budget_us: req.write_pause_budget_us,
42 started_at_hlc: nodedb_types::Hlc::default(),
43 },
44 )
45 .await?;
46
47 info!(
48 vshard = req.vshard_id,
49 group = group_id,
50 target = req.target_node,
51 entries = committed,
52 "phase 1: adding target to raft group"
53 );
54
55 let change = ConfChange {
56 change_type: ConfChangeType::AddLearner,
57 node_id: req.target_node,
58 };
59 let learner_log_index = {
60 let mut mr = ex.multi_raft.lock().unwrap_or_else(|p| p.into_inner());
61 mr.propose_conf_change(group_id, &change)?;
62 mr.group_statuses()
63 .iter()
64 .find(|s| s.group_id == group_id)
65 .map(|s| s.commit_index)
66 .unwrap_or(committed)
67 };
68
69 if let Some(node_info) = {
70 let topo = ex.topology.read().unwrap_or_else(|p| p.into_inner());
71 topo.get_node(req.target_node).map(|n| n.addr.clone())
72 } && let Ok(addr) = node_info.parse()
73 {

Callers 2

executeMethod · 0.85

Calls 13

lockMethod · 0.80
start_base_copyMethod · 0.80
propose_checkpointMethod · 0.80
get_nodeMethod · 0.80
register_peerMethod · 0.80
update_base_copyMethod · 0.80
findMethod · 0.45
iterMethod · 0.45
group_statusesMethod · 0.45
propose_conf_changeMethod · 0.45
readMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected