fix(mito2): merge staging manifest files in all_manifest_files

The original implementation only read the normal manifest
(manifest_ctx.manifest()) and skipped staging_manifest(). While the
region is in staging mode (e.g. region copy/migration), the authoritative
live file set lives in the staging manifest, so callers would silently
miss those files.

Now matches the semantics of manifest_sst_entries() (~L771), which
explicitly merges manifest().files with staging_manifest().files via a
HashMap collect (dedup by FileId). The returned manifest version is the
staging version when a staging manifest is present, otherwise the normal
manifest version.

Also removed downstream-specific references from the rustdoc comments.
This commit is contained in:
Ning Sun
2026-07-29 21:44:33 +08:00
parent 8d490693b1
commit cb37f9e78c
+32 -5
View File
@@ -850,14 +850,41 @@ impl MitoRegion {
}
/// Returns all live SST file metas and the current manifest version from
/// the region manifest.
/// the region manifest, merging both the normal and staging manifests.
///
/// Used by the Iceberg rebuild admin path to enumerate the authoritative
/// live file set without going through the worker loop.
/// While the region is in staging mode (e.g. during region copy/migration),
/// the authoritative live file set lives in the staging manifest, so this
/// method merges both — matching the semantics of [`manifest_sst_entries`].
///
/// The returned manifest version is the staging version when a staging
/// manifest is present, otherwise the normal manifest version.
pub async fn all_manifest_files(&self) -> (Vec<FileMeta>, ManifestVersion) {
let manifest = self.manifest_ctx.manifest().await;
let files = manifest.files.values().cloned().collect();
(files, manifest.manifest_version)
let staging = self
.manifest_ctx
.staging_manifest()
.await
.map(|m| (m.files.clone(), m.manifest_version));
let version = staging
.as_ref()
.map(|(_, v)| *v)
.unwrap_or(manifest.manifest_version);
let files = match staging {
Some((staging_files, _)) => {
let merged = manifest
.files
.clone()
.into_iter()
.chain(staging_files)
.collect::<std::collections::HashMap<_, _>>();
merged.into_values().collect()
}
None => manifest.files.values().cloned().collect(),
};
(files, version)
}
/// Exit staging mode successfully by merging all staged manifests and making them visible.