fix(replication): fence stale metadata status writeback (#7083)

Co-authored-by: houseme <housemecn@gmail.com>
This commit is contained in:
cxymds
2026-09-03 16:05:58 +08:00
committed by GitHub
parent 8023cf3e26
commit 86ebcb325c
29 changed files with 3219 additions and 229 deletions
+19
View File
@@ -363,6 +363,25 @@ impl FileMeta {
}
}
// `fi.metadata` is the authoritative replacement
// for every internal suffix it carries. Remove all
// existing RustFS/MinIO and mixed-case aliases for
// those suffixes before inserting the new map;
// otherwise an old MinIO key survives this RMW and
// conflicts with newly written canonical aliases.
let replaced_internal_suffixes = fi
.metadata
.keys()
.filter_map(|key| rustfs_utils::http::strip_internal_prefix_preserving_case(key))
.map(str::to_ascii_lowercase)
.collect::<std::collections::HashSet<_>>();
if !replaced_internal_suffixes.is_empty() {
obj.meta_sys.retain(|key, _| {
rustfs_utils::http::strip_internal_prefix_preserving_case(key)
.is_none_or(|suffix| !replaced_internal_suffixes.contains(&suffix.to_ascii_lowercase()))
});
}
for (k, v) in fi.metadata.iter() {
// Split metadata into meta_user and meta_sys based on prefix
// This logic must match From<FileInfo> for MetaObject
+6 -1
View File
@@ -2861,7 +2861,12 @@ impl From<FileInfo> for MetaObject {
}
}
fn get_internal_replication_state(metadata: &HashMap<String, String>) -> Option<ReplicationState> {
/// Rebuild the structured replication state from its durable internal metadata.
///
/// Mutation paths that update internal replication keys on an existing
/// [`FileInfo`] must use this parser before serializing xl.meta so the metadata
/// map and the structured state cannot diverge.
pub fn get_internal_replication_state(metadata: &HashMap<String, String>) -> Option<ReplicationState> {
let mut rs = ReplicationState::default();
let mut has = false;