Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions internal/jobs/expire.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"log/slog"
"strings"
"sync/atomic"
"time"

madmin "github.com/minio/madmin-go/v3"
Expand Down Expand Up @@ -570,7 +571,11 @@ func deleteStorageObjects(ctx context.Context, deleter S3BackupDeleter, bucket,
// with thousands of objects doesn't pull the whole listing into memory —
// the same pipe pattern as team_deletion_executor.deleteS3BackupsForToken.
objectsCh := make(chan minio.ObjectInfo, 32)
var objectCount int
// objectCount is incremented in the producer goroutine below and read
// after the RemoveObjects drain loop on the consumer side — use an
// atomic so the cross-goroutine read in the final slog is race-free
// (the -race build flagged the plain-int read otherwise).
var objectCount atomic.Int64
go func() {
defer close(objectsCh)
defer func() {
Expand All @@ -591,7 +596,7 @@ func deleteStorageObjects(ctx context.Context, deleter S3BackupDeleter, bucket,
)
return
}
objectCount++
objectCount.Add(1)
select {
case objectsCh <- obj:
case <-ctx.Done():
Expand All @@ -617,7 +622,7 @@ func deleteStorageObjects(ctx context.Context, deleter S3BackupDeleter, bucket,
"resource_id", resourceID,
"token", logsafe.Token(token),
"prefix", prefix,
"objects_listed", objectCount,
"objects_listed", objectCount.Load(),
"remove_errors", removeErrors,
"job_id", jobID,
)
Expand Down
Loading
Loading