From 3a7ab3b8eb68faa43cf709e8677a2580afb5a906 Mon Sep 17 00:00:00 2001 From: Seebs Date: Fri, 17 Apr 2020 14:21:41 -0500 Subject: [PATCH] GroupBy should terminate even if the last result is empty If you have two criteria, and the last result you generate is empty, the nextAtIdx iterator for i==1 will try to continue poking the i==0 iterator. That one produces a nil result, and declares the entire group-by iterator done... But the nextAtIdx call above it isn't checking that, and just loops forever. This causes some queries to become stuck permanently, consuming ridiculous amounts of resources almost entirely focused on calling Intersect millions of times to get empty results. --- executor.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/executor.go b/executor.go index d9622329d..3badd4906 100644 --- a/executor.go +++ b/executor.go @@ -4665,6 +4665,9 @@ func (gbi *groupByIterator) nextAtIdx(i int) { } if wrapped && i != 0 { gbi.nextAtIdx(i - 1) + if gbi.done { + return + } } if i == 0 && gbi.filter != nil { gbi.rows[i].row = nr.Intersect(gbi.filter)