Commit Graph

3 Commits

Author SHA1 Message Date
Aaron Son
9b763af5a6 libraries/utils/async/ring_buffer.go: PR feedback. Return error on epoch mismatch. 2021-03-24 15:45:58 -07:00
Aaron Son
b77f2bad8c go/libraries/doltcore/sqle/async_indexed_lookups.go: Fix leaking of results from one index lookup to another.
When a query with an index lookup as a LIMIT, it's possible for the result
iterator to be closed before all the index results have been streamed. When
that happens, we can end up with queueRows goroutine which is enqueuing rows
into a ring buffer that is going to be used by a different query later.

This PR adds two mechanisms, one to stop the wrong results from being seen and
to cancel the unnecessary work.

1. RingBuffer gets an epoch, which is incremented on each Reset(). If a given
   Push does not match the current epoch, then nothing is added to the ring
   buffer.

2. queueRows is run with a cancelable (sub-)Context, and that Context is
   canceled when the corresponding iterator is Closed().
2021-03-24 14:11:09 -07:00
Brian Hendriks
69de83a757 Fixed worker pool used for index lookups (#1304) 2021-02-16 17:28:20 -08:00