Apply a single undo operation to rollback changes
(
&self,
operation: &crate::txn::UndoOperation,
storage: &Arc<crate::storage::StorageManager>,
)
| 224 | |
| 225 | /// Apply a single undo operation to rollback changes |
| 226 | fn apply_undo_operation( |
| 227 | &self, |
| 228 | operation: &crate::txn::UndoOperation, |
| 229 | storage: &Arc<crate::storage::StorageManager>, |
| 230 | ) -> Result<(), ExecutionError> { |
| 231 | use crate::txn::UndoOperation; |
| 232 | |
| 233 | match operation { |
| 234 | UndoOperation::Batch { operations } => { |
| 235 | // Handle batch operations - undo all operations in the batch atomically |
| 236 | log::info!( |
| 237 | "ROLLBACK: Processing batch with {} operations", |
| 238 | operations.len() |
| 239 | ); |
| 240 | for (i, op) in operations.iter().enumerate() { |
| 241 | log::debug!( |
| 242 | "ROLLBACK: Applying batch operation {}/{}", |
| 243 | i + 1, |
| 244 | operations.len() |
| 245 | ); |
| 246 | self.apply_undo_operation(op, storage)?; |
| 247 | } |
| 248 | log::info!( |
| 249 | "ROLLBACK: Successfully processed batch of {} operations", |
| 250 | operations.len() |
| 251 | ); |
| 252 | } |
| 253 | UndoOperation::InsertNode { |
| 254 | graph_path, |
| 255 | node_id, |
| 256 | } => { |
| 257 | log::info!( |
| 258 | "ROLLBACK: Undoing InsertNode: graph={}, node={}", |
| 259 | graph_path, |
| 260 | node_id |
| 261 | ); |
| 262 | |
| 263 | // Load the graph |
| 264 | let mut graph = storage |
| 265 | .get_graph(graph_path) |
| 266 | .map_err(|e| { |
| 267 | ExecutionError::StorageError(format!( |
| 268 | "Failed to load graph for rollback: {}", |
| 269 | e |
| 270 | )) |
| 271 | })? |
| 272 | .ok_or_else(|| { |
| 273 | ExecutionError::StorageError(format!( |
| 274 | "Graph not found for rollback: {}", |
| 275 | graph_path |
| 276 | )) |
| 277 | })?; |
| 278 | |
| 279 | log::info!( |
| 280 | "ROLLBACK: Graph loaded, current node count: {}", |
| 281 | graph.node_count().unwrap_or(0) |
| 282 | ); |
| 283 |
no test coverage detected