mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-09-07 05:59:00 +00:00
feat: expose MitoRegion::all_manifest_files for metadata rebuild (#8680)
* feat: expose MitoRegion::all_manifest_files for metadata rebuild Adds a public read-only accessor that returns all live SST file metas and the current manifest version from the region manifest. Used by the downstream project admin path to enumerate the authoritative live file set without going through the worker loop. * 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:
@@ -849,6 +849,44 @@ impl MitoRegion {
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
|
||||
/// Returns all live SST file metas and the current manifest version from
|
||||
/// the region manifest, merging both the normal and staging manifests.
|
||||
///
|
||||
/// 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 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.
|
||||
/// Merges staged manifest actions into the live manifest and exits staging mode.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user