feat: Add error join for file writing in snapshots (#26004) (#26005)

This PR adds an error join to help with handling multiple errors
from snapshot file writers.

(cherry picked from commit 4ad5e2aba7)
pull/26025/head
WeblWabl 2025-02-12 16:12:36 -06:00 committed by GitHub
parent 5149774e22
commit 982ae57f22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -890,12 +890,12 @@ func (c *Compactor) WriteSnapshot(cache *Cache, logger *zap.Logger) ([]string, e
}(splits[i])
}
var err error
var errs []error
files := make([]string, 0, concurrency)
for i := 0; i < concurrency; i++ {
result := <-resC
if result.err != nil {
err = result.err
errs = append(errs, result.err)
}
files = append(files, result.files...)
}
@ -914,7 +914,7 @@ func (c *Compactor) WriteSnapshot(cache *Cache, logger *zap.Logger) ([]string, e
return nil, errSnapshotsDisabled
}
return files, err
return files, errors.Join(errs...)
}
// compact writes multiple smaller TSM files into 1 or more larger files.