From 7b7d780fffd8981e48c89096ef0e14400e625ca5 Mon Sep 17 00:00:00 2001 From: Carlo Mion Date: Thu, 4 Nov 2021 09:24:12 +0100 Subject: [PATCH] stats: fix missing StatsInfo fields in the computation of the group sum --- fs/accounting/stats.go | 2 ++ fs/accounting/stats_groups.go | 32 ++++++++++++++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/fs/accounting/stats.go b/fs/accounting/stats.go index fe1fdf11c..b4b32a8ee 100644 --- a/fs/accounting/stats.go +++ b/fs/accounting/stats.go @@ -24,6 +24,8 @@ const ( var MaxCompletedTransfers = 100 // StatsInfo accounts all transfers +// N.B.: if this struct is modified, please remember to also update sum() function in stats_groups +// to correctly count the updated fields type StatsInfo struct { mu sync.RWMutex ctx context.Context diff --git a/fs/accounting/stats_groups.go b/fs/accounting/stats_groups.go index 400c72924..28548cfc9 100644 --- a/fs/accounting/stats_groups.go +++ b/fs/accounting/stats_groups.go @@ -359,23 +359,31 @@ func (sg *statsGroups) sum(ctx context.Context) *StatsInfo { { sum.bytes += stats.bytes sum.errors += stats.errors - sum.fatalError = sum.fatalError || stats.fatalError - sum.retryError = sum.retryError || stats.retryError - sum.checks += stats.checks - sum.transfers += stats.transfers - sum.deletes += stats.deletes - sum.deletedDirs += stats.deletedDirs - sum.renames += stats.renames - sum.checking.merge(stats.checking) - sum.transferring.merge(stats.transferring) - sum.inProgress.merge(stats.inProgress) if sum.lastError == nil && stats.lastError != nil { sum.lastError = stats.lastError } - sum.startedTransfers = append(sum.startedTransfers, stats.startedTransfers...) + sum.fatalError = sum.fatalError || stats.fatalError + sum.retryError = sum.retryError || stats.retryError + if stats.retryAfter.After(sum.retryAfter) { + // Update the retryAfter field only if it is a later date than the current one in the sum + sum.retryAfter = stats.retryAfter + } + sum.checks += stats.checks + sum.checking.merge(stats.checking) + sum.checkQueue += stats.checkQueue + sum.checkQueueSize += stats.checkQueueSize + sum.transfers += stats.transfers + sum.transferring.merge(stats.transferring) sum.transferQueueSize += stats.transferQueueSize - sum.oldDuration += stats.oldDuration + sum.renames += stats.renames + sum.renameQueue += stats.renameQueue + sum.renameQueueSize += stats.renameQueueSize + sum.deletes += stats.deletes + sum.deletedDirs += stats.deletedDirs + sum.inProgress.merge(stats.inProgress) + sum.startedTransfers = append(sum.startedTransfers, stats.startedTransfers...) sum.oldTimeRanges = append(sum.oldTimeRanges, stats.oldTimeRanges...) + sum.oldDuration += stats.oldDuration stats.average.mu.Lock() sum.average.speed += stats.average.speed stats.average.mu.Unlock()