(
sm: &SnapshotManager,
tm: &TagManager,
retained_snapshot_id: i64,
)
| 328 | } |
| 329 | |
| 330 | async fn clean_larger_than( |
| 331 | sm: &SnapshotManager, |
| 332 | tm: &TagManager, |
| 333 | retained_snapshot_id: i64, |
| 334 | ) -> DFResult<()> { |
| 335 | // 1. Update LATEST hint |
| 336 | sm.write_latest_hint(retained_snapshot_id) |
| 337 | .await |
| 338 | .map_err(to_datafusion_error)?; |
| 339 | |
| 340 | // 2. Delete snapshots newer than the target |
| 341 | let all_ids = sm.list_all_ids().await.map_err(to_datafusion_error)?; |
| 342 | for &id in all_ids.iter().rev() { |
| 343 | if id <= retained_snapshot_id { |
| 344 | break; |
| 345 | } |
| 346 | sm.delete_snapshot(id).await.map_err(to_datafusion_error)?; |
| 347 | } |
| 348 | |
| 349 | // TODO: clean long-lived changelogs newer than retained_snapshot_id |
| 350 | // Java's RollbackHelper.cleanLargerThan also calls cleanLongLivedChangelogs here. |
| 351 | // Implement once ChangelogManager is available. |
| 352 | |
| 353 | // 3. Delete tags that reference snapshots newer than the target |
| 354 | let tags = tm.list_all().await.map_err(to_datafusion_error)?; |
| 355 | for (name, snap) in tags.iter().rev() { |
| 356 | if snap.id() <= retained_snapshot_id { |
| 357 | continue; |
| 358 | } |
| 359 | tm.delete(name).await.map_err(to_datafusion_error)?; |
| 360 | } |
| 361 | |
| 362 | Ok(()) |
| 363 | } |
| 364 | |
| 365 | async fn proc_rollback_to( |
| 366 | ctx: &SessionContext, |
no test coverage detected