mirror of
https://github.com/rustfs/rustfs.git
synced 2026-09-07 12:35:54 +00:00
fix(replication): fence stale metadata status writeback (#7083)
Co-authored-by: houseme <housemecn@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user