Skip to content

Commit

Permalink
fix: return MergeIterator.Close errors (#24975) (#24997) (#24998)
Browse files Browse the repository at this point in the history
Ensure that errors from closing the
iterators underneath a MergeIterator
are returned up the stack.

(cherry picked from commit 5fda409)

closes #24977

(cherry picked from commit a97566b)

closes #24978
  • Loading branch information
davidby-influx authored May 14, 2024
1 parent bc42088 commit 00b6888
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
26 changes: 16 additions & 10 deletions influxql/query/iterator.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package query
import (
"container/heap"
"context"
"errors"
"io"
"sort"
"sync"
Expand Down Expand Up @@ -162,14 +163,15 @@ func (itr *floatMergeIterator) Close() error {
itr.mu.Lock()
defer itr.mu.Unlock()

var errs []error
for _, input := range itr.inputs {
input.Close()
errs = append(errs, input.Close())
}
itr.curr = nil
itr.inputs = nil
itr.heap.items = nil
itr.closed = true
return nil
return errors.Join(errs...)
}

// Next returns the next point from the iterator.
Expand Down Expand Up @@ -2825,14 +2827,15 @@ func (itr *integerMergeIterator) Close() error {
itr.mu.Lock()
defer itr.mu.Unlock()

var errs []error
for _, input := range itr.inputs {
input.Close()
errs = append(errs, input.Close())
}
itr.curr = nil
itr.inputs = nil
itr.heap.items = nil
itr.closed = true
return nil
return errors.Join(errs...)
}

// Next returns the next point from the iterator.
Expand Down Expand Up @@ -5488,14 +5491,15 @@ func (itr *unsignedMergeIterator) Close() error {
itr.mu.Lock()
defer itr.mu.Unlock()

var errs []error
for _, input := range itr.inputs {
input.Close()
errs = append(errs, input.Close())
}
itr.curr = nil
itr.inputs = nil
itr.heap.items = nil
itr.closed = true
return nil
return errors.Join(errs...)
}

// Next returns the next point from the iterator.
Expand Down Expand Up @@ -8151,14 +8155,15 @@ func (itr *stringMergeIterator) Close() error {
itr.mu.Lock()
defer itr.mu.Unlock()

var errs []error
for _, input := range itr.inputs {
input.Close()
errs = append(errs, input.Close())
}
itr.curr = nil
itr.inputs = nil
itr.heap.items = nil
itr.closed = true
return nil
return errors.Join(errs...)
}

// Next returns the next point from the iterator.
Expand Down Expand Up @@ -10800,14 +10805,15 @@ func (itr *booleanMergeIterator) Close() error {
itr.mu.Lock()
defer itr.mu.Unlock()

var errs []error
for _, input := range itr.inputs {
input.Close()
errs = append(errs, input.Close())
}
itr.curr = nil
itr.inputs = nil
itr.heap.items = nil
itr.closed = true
return nil
return errors.Join(errs...)
}

// Next returns the next point from the iterator.
Expand Down
6 changes: 4 additions & 2 deletions influxql/query/iterator.gen.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package query
import (
"context"
"container/heap"
"errors"
"io"
"sort"
"sync"
Expand Down Expand Up @@ -159,14 +160,15 @@ func (itr *{{$k.name}}MergeIterator) Close() error {
itr.mu.Lock()
defer itr.mu.Unlock()

var errs []error
for _, input := range itr.inputs {
input.Close()
errs = append(errs, input.Close())
}
itr.curr = nil
itr.inputs = nil
itr.heap.items = nil
itr.closed = true
return nil
return errors.Join(errs...)
}

// Next returns the next point from the iterator.
Expand Down

0 comments on commit 00b6888

Please sign in to comment.