From 288c063e0e9810dc61a355d492152e2c1c82f55a Mon Sep 17 00:00:00 2001 From: kai Date: Mon, 6 Mar 2023 09:28:35 +0000 Subject: [PATCH] Fix nil reference panic when a scan fails to start - do not add an iterator to Hub.runningIterators until scan is started successfully. Closes #298 --- hub/hub.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hub/hub.go b/hub/hub.go index 0566901c..b8d0c42a 100644 --- a/hub/hub.go +++ b/hub/hub.go @@ -34,7 +34,9 @@ const ( // Hub is a structure representing plugin hub type Hub struct { - connections *connectionFactory + connections *connectionFactory + + // list of iterators currently executing scans runningIterators []Iterator // if the cache is enabled/disabled by a metacommand, this will be non null @@ -308,8 +310,6 @@ func (h *Hub) GetIterator(columns []string, quals *proto.Quals, unhandledRestric return nil, err } - // store the iterator - h.addIterator(iterator) return iterator, nil } @@ -698,6 +698,10 @@ func (h *Hub) StartScan(i Iterator) error { return err } iterator.Start(stream, ctx, cancel) + + // add iterator to running list + h.addIterator(iterator) + return nil }