mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-28 07:57:01 +00:00
fix(ecstore): guard free-version decommission conflicts
This commit is contained in:
@@ -2640,8 +2640,12 @@ fn determine_decommission_final_state(items_failed: usize, was_cancelled: bool)
|
||||
}
|
||||
}
|
||||
|
||||
fn decommission_remaining_version_count(total_versions: usize, expired: usize) -> usize {
|
||||
total_versions.saturating_sub(expired)
|
||||
fn decommission_remaining_version_count(versions: &[rustfs_filemeta::FileInfo], expired: usize) -> usize {
|
||||
versions
|
||||
.iter()
|
||||
.filter(|version| !version.tier_free_version())
|
||||
.count()
|
||||
.saturating_sub(expired)
|
||||
}
|
||||
|
||||
fn should_skip_decommission_delete_marker(
|
||||
@@ -3954,7 +3958,7 @@ impl ECStore {
|
||||
continue;
|
||||
}
|
||||
|
||||
let remaining_versions = decommission_remaining_version_count(fivs.versions.len(), expired);
|
||||
let remaining_versions = decommission_remaining_version_count(&fivs.versions, expired);
|
||||
if should_skip_decommission_delete_marker(version, remaining_versions, replication_config.is_some()) {
|
||||
//
|
||||
decommissioned += 1;
|
||||
@@ -4419,6 +4423,39 @@ impl ECStore {
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) async fn decommission_entry_for_test_with_bucket_incarnation(
|
||||
self: &Arc<Self>,
|
||||
idx: usize,
|
||||
entry: MetaCacheEntry,
|
||||
bucket: String,
|
||||
set: Arc<SetDisks>,
|
||||
) -> Result<()> {
|
||||
let expected_bucket_incarnation_id = if is_meta_bucketname(&bucket) {
|
||||
None
|
||||
} else {
|
||||
Some(self.bucket_incarnation_id_from_disk(&bucket).await?)
|
||||
};
|
||||
self.decommission_entry(
|
||||
CancellationToken::new(),
|
||||
idx,
|
||||
OffsetDateTime::now_utc(),
|
||||
entry,
|
||||
bucket,
|
||||
set,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
expected_bucket_incarnation_id,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) async fn check_after_decommission_for_test(self: &Arc<Self>, idx: usize) -> Result<()> {
|
||||
self.check_after_decommission(idx).await
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(self, rx))]
|
||||
async fn decommission_pool(
|
||||
self: &Arc<Self>,
|
||||
@@ -5459,13 +5496,6 @@ mod tests {
|
||||
assert_eq!(determine_decommission_final_state(0, true), DecommissionFinalState::Failed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn decommission_remaining_version_count_excludes_only_expired_versions() {
|
||||
assert_eq!(decommission_remaining_version_count(1, 0), 1);
|
||||
assert_eq!(decommission_remaining_version_count(2, 1), 1);
|
||||
assert_eq!(decommission_remaining_version_count(1, 1), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lifecycle_action_removes_data_movement_version_rejects_delete_marker_action() {
|
||||
assert!(!lifecycle_action_removes_data_movement_version(IlmAction::DeleteAction));
|
||||
|
||||
Reference in New Issue
Block a user