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

Method execute

nodedb-cluster/src/migration_executor/executor.rs:105–187  ·  view source on GitHub ↗
(&self, req: MigrationRequest)

Source from the content-addressed store, hash-verified

103 }
104
105 pub async fn execute(&self, req: MigrationRequest) -> Result<MigrationResult> {
106 let source_group = {
107 let routing = self.routing.read().unwrap_or_else(|p| p.into_inner());
108 routing.group_for_vshard(req.vshard_id)?
109 };
110
111 if let Some(state_table) = &self.migration_state {
112 let guard = state_table.lock().unwrap_or_else(|p| p.into_inner());
113 for row in guard.all_checkpoints() {
114 if let Some(_id) = row.migration_uuid() {
115 let vshard_matches = match &row.payload {
116 MigrationCheckpointPayload::AddLearner { vshard_id, .. } => {
117 *vshard_id == req.vshard_id
118 }
119 MigrationCheckpointPayload::CatchUp { vshard_id, .. } => {
120 *vshard_id == req.vshard_id
121 }
122 MigrationCheckpointPayload::PromoteLearner { vshard_id, .. } => {
123 *vshard_id == req.vshard_id
124 }
125 MigrationCheckpointPayload::LeadershipTransfer { vshard_id, .. } => {
126 *vshard_id == req.vshard_id
127 }
128 MigrationCheckpointPayload::Cutover { vshard_id, .. } => {
129 *vshard_id == req.vshard_id
130 }
131 MigrationCheckpointPayload::Complete { vshard_id, .. } => {
132 *vshard_id == req.vshard_id
133 }
134 };
135 if vshard_matches && row.payload.phase_tag() != MigrationPhaseTag::Complete {
136 return Err(ClusterError::MigrationInProgress {
137 vshard_id: req.vshard_id,
138 });
139 }
140 }
141 }
142 }
143
144 let migration_id = Uuid::new_v4();
145
146 let mut state = MigrationState::new(
147 req.vshard_id,
148 source_group,
149 source_group,
150 req.source_node,
151 req.target_node,
152 req.write_pause_budget_us,
153 );
154
155 info!(
156 vshard = req.vshard_id,
157 source = req.source_node,
158 target = req.target_node,
159 group = source_group,
160 migration_id = %migration_id,
161 "starting vShard migration"
162 );

Callers

nothing calls this directly

Calls 12

phase1_base_copyFunction · 0.85
phase2_wal_catchupFunction · 0.85
phase3_cutoverFunction · 0.85
group_for_vshardMethod · 0.80
lockMethod · 0.80
all_checkpointsMethod · 0.80
migration_uuidMethod · 0.80
phase_tagMethod · 0.80
elapsedMethod · 0.80
phaseMethod · 0.80
readMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected