Apply a `MigrationAbort` entry against the shared state table and live routing table. Applies each compensation in order; any failure is fatal (no warn-and-continue — a partial abort is as broken as a partial commit). On success, removes the migration row from the state table.
(
table: &SharedMigrationStateTable,
routing: Option<&std::sync::Arc<std::sync::RwLock<RoutingTable>>>,
migration_id: uuid::Uuid,
reason: &str,
compensations: &[Compensation],
)
| 195 | /// warn-and-continue — a partial abort is as broken as a partial commit). |
| 196 | /// On success, removes the migration row from the state table. |
| 197 | pub fn apply_migration_abort( |
| 198 | table: &SharedMigrationStateTable, |
| 199 | routing: Option<&std::sync::Arc<std::sync::RwLock<RoutingTable>>>, |
| 200 | migration_id: uuid::Uuid, |
| 201 | reason: &str, |
| 202 | compensations: &[Compensation], |
| 203 | ) -> Result<(), ClusterError> { |
| 204 | info!( |
| 205 | migration_id = %migration_id, |
| 206 | reason, |
| 207 | steps = compensations.len(), |
| 208 | "applying migration abort" |
| 209 | ); |
| 210 | |
| 211 | for (step, comp) in compensations.iter().enumerate() { |
| 212 | apply_compensation(routing, step, migration_id, comp)?; |
| 213 | } |
| 214 | |
| 215 | let mut guard = table.lock().unwrap_or_else(|p| p.into_inner()); |
| 216 | guard.remove(&migration_id) |
| 217 | } |
| 218 | |
| 219 | fn apply_compensation( |
| 220 | routing: Option<&std::sync::Arc<std::sync::RwLock<RoutingTable>>>, |