fix: ensure TSMBatchKeyIterator and FileStore close all TSMReaders (#24957)

Do not let errors on closing 
a TSMReader prevent other 
closes.
pull/24985/head
davidby-influx 2024-05-06 09:59:30 -07:00 committed by GitHub
parent d4b16dcd98
commit 82cbdb5478
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 11 deletions

View File

@ -14,6 +14,7 @@ package tsm1
import (
"bytes"
"errors"
"fmt"
"io"
"math"
@ -1630,15 +1631,14 @@ func (k *tsmBatchKeyIterator) Close() error {
k.values = nil
k.pos = nil
k.iterators = nil
var errSlice []error
for _, r := range k.readers {
if err := r.Close(); err != nil {
return err
}
errSlice = append(errSlice, r.Close())
}
return nil
return errors.Join(errSlice...)
}
// Error returns any errors encountered during iteration.
// Err error returns any errors encountered during iteration.
func (k *tsmBatchKeyIterator) Err() error {
if len(k.errs) == 0 {
return nil

View File

@ -645,14 +645,12 @@ func (f *FileStore) Close() error {
// Let other methods access this closed object while we do the actual closing.
f.mu.Unlock()
for _, file := range files {
err := file.Close()
if err != nil {
return err
}
var errSlice []error
for _, tsmFile := range files {
errSlice = append(errSlice, tsmFile.Close())
}
return nil
return errors.Join(errSlice...)
}
func (f *FileStore) DiskSizeBytes() int64 {