mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
Fix uninitialized replication stats (#20260)
Services are unfrozen before `initBackgroundReplication` is finished. This means that the globalReplicationStats write is racy. Switch to an atomic pointer. Provide the `ReplicationPool` with the stats, so it doesn't have to be grabbed from the atomic pointer on every use. All other loads and checks are nil, and calls return empty values when stats still haven't been initialized.
This commit is contained in:
@@ -537,7 +537,7 @@ func (sys *NotificationSys) LoadBucketMetadata(ctx context.Context, bucketName s
|
||||
|
||||
// DeleteBucketMetadata - calls DeleteBucketMetadata call on all peers
|
||||
func (sys *NotificationSys) DeleteBucketMetadata(ctx context.Context, bucketName string) {
|
||||
globalReplicationStats.Delete(bucketName)
|
||||
globalReplicationStats.Load().Delete(bucketName)
|
||||
globalBucketMetadataSys.Remove(bucketName)
|
||||
globalBucketTargetSys.Delete(bucketName)
|
||||
globalEventNotifier.RemoveNotification(bucketName)
|
||||
@@ -591,7 +591,7 @@ func (sys *NotificationSys) GetClusterAllBucketStats(ctx context.Context) []Buck
|
||||
}
|
||||
}
|
||||
|
||||
replicationStatsList := globalReplicationStats.GetAll()
|
||||
replicationStatsList := globalReplicationStats.Load().GetAll()
|
||||
bucketStatsMap := BucketStatsMap{
|
||||
Stats: make(map[string]BucketStats, len(replicationStatsList)),
|
||||
Timestamp: UTCNow(),
|
||||
@@ -599,7 +599,7 @@ func (sys *NotificationSys) GetClusterAllBucketStats(ctx context.Context) []Buck
|
||||
for k, replicationStats := range replicationStatsList {
|
||||
bucketStatsMap.Stats[k] = BucketStats{
|
||||
ReplicationStats: replicationStats,
|
||||
ProxyStats: globalReplicationStats.getProxyStats(k),
|
||||
ProxyStats: globalReplicationStats.Load().getProxyStats(k),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -632,11 +632,13 @@ func (sys *NotificationSys) GetClusterBucketStats(ctx context.Context, bucketNam
|
||||
peersLogOnceIf(logger.SetReqInfo(ctx, reqInfo), nErr.Err, nErr.Host.String())
|
||||
}
|
||||
}
|
||||
bucketStats = append(bucketStats, BucketStats{
|
||||
ReplicationStats: globalReplicationStats.Get(bucketName),
|
||||
QueueStats: ReplicationQueueStats{Nodes: []ReplQNodeStats{globalReplicationStats.getNodeQueueStats(bucketName)}},
|
||||
ProxyStats: globalReplicationStats.getProxyStats(bucketName),
|
||||
})
|
||||
if st := globalReplicationStats.Load(); st != nil {
|
||||
bucketStats = append(bucketStats, BucketStats{
|
||||
ReplicationStats: st.Get(bucketName),
|
||||
QueueStats: ReplicationQueueStats{Nodes: []ReplQNodeStats{st.getNodeQueueStats(bucketName)}},
|
||||
ProxyStats: st.getProxyStats(bucketName),
|
||||
})
|
||||
}
|
||||
return bucketStats
|
||||
}
|
||||
|
||||
@@ -665,7 +667,7 @@ func (sys *NotificationSys) GetClusterSiteMetrics(ctx context.Context) []SRMetri
|
||||
peersLogOnceIf(logger.SetReqInfo(ctx, reqInfo), nErr.Err, nErr.Host.String())
|
||||
}
|
||||
}
|
||||
siteStats = append(siteStats, globalReplicationStats.getSRMetricsForNode())
|
||||
siteStats = append(siteStats, globalReplicationStats.Load().getSRMetricsForNode())
|
||||
return siteStats
|
||||
}
|
||||
|
||||
@@ -1605,7 +1607,7 @@ func (sys *NotificationSys) GetReplicationMRF(ctx context.Context, bucket, node
|
||||
if node != "all" && node != globalLocalNodeName {
|
||||
return nil
|
||||
}
|
||||
mCh, err := globalReplicationPool.getMRF(ctx, bucket)
|
||||
mCh, err := globalReplicationPool.Get().getMRF(ctx, bucket)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user