java-topology/defects/minio/patch/minio-0002-decom-isBucketDecommissioned-linear-scan.patch

50 lines
1.9 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# UNDF: UNDF-2026-000000769
# UNDF: (leave blank)
# minio-0002: isBucketDecommissioned() uses slices.Contains(DecommissionedBuckets, bucket) → O(P×D)
#
# File: cmd/erasure-server-pool-decom.go
# Function: PoolDecommissionInfo.isBucketDecommissioned()
#
# Called from:
# - decommissionInBackground() line 1083: loops over pending buckets (P),
# each calling isBucketDecommissioned which scans DecommissionedBuckets (D).
# Total: O(P × D). As decommission progresses, D grows toward total buckets.
# - bucketPush() line 126: loops over QueuedBuckets (Q), each calling
# isBucketDecommissioned. Total: O(Q × D).
#
# Fix: add a decomBucketSet map[string]struct{} field for O(1) lookup.
# Severity: MEDIUM (O(B²) during pool decommission, B = number of buckets)
# Overhead ratio: ~250x at B=500
#
--- a/cmd/erasure-server-pool-decom.go
+++ b/cmd/erasure-server-pool-decom.go
@@ -56,6 +56,7 @@
type PoolDecommissionInfo struct {
// ... existing fields ...
DecommissionedBuckets []string `json:"-" msg:"dbkts"`
+ decomBucketSet map[string]struct{} `json:"-" msg:"-"` // O(1) mirror
@@ -100,6 +101,10 @@
func (pd *PoolDecommissionInfo) bucketDone(bucket string) {
pd.DecommissionedBuckets = append(pd.DecommissionedBuckets, bucket)
+ if pd.decomBucketSet == nil {
+ pd.decomBucketSet = make(map[string]struct{})
+ }
+ pd.decomBucketSet[bucket] = struct{}{}
}
@@ -120,7 +125,11 @@
func (pd *PoolDecommissionInfo) isBucketDecommissioned(bucket string) bool {
- return slices.Contains(pd.DecommissionedBuckets, bucket)
+ if pd.decomBucketSet != nil {
+ _, ok := pd.decomBucketSet[bucket]
+ return ok
+ }
+ // Fallback for freshly deserialized state (rebuild set on first call)
+ pd.decomBucketSet = make(map[string]struct{}, len(pd.DecommissionedBuckets))
+ for _, b := range pd.DecommissionedBuckets {
+ pd.decomBucketSet[b] = struct{}{}
+ }
+ _, ok := pd.decomBucketSet[bucket]
+ return ok
}