fix(upload): add 30s timeout to background chunk cleanup goroutine
The cleanup goroutine used context.Background() with no timeout, so if MinIO accepted TCP connections but never responded, the goroutine would block indefinitely. Now uses context.WithTimeout to prevent leaks.
This commit is contained in:
@@ -357,8 +357,9 @@ func (s *UploadService) CompleteUpload(ctx context.Context, sessionID int64) (*m
|
||||
keys[i] = fmt.Sprintf("%schunk_%05d", minioPrefix, i)
|
||||
}
|
||||
go func() {
|
||||
bgCtx := context.Background()
|
||||
if delErr := s.storage.RemoveObjects(bgCtx, s.cfg.Bucket, keys, storage.RemoveObjectsOptions{}); delErr != nil {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
if delErr := s.storage.RemoveObjects(ctx, s.cfg.Bucket, keys, storage.RemoveObjectsOptions{}); delErr != nil {
|
||||
s.logger.Warn("delete temp chunks", zap.Error(delErr))
|
||||
}
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user