From 47b7f512da1143818b41006b6c265804239d9804 Mon Sep 17 00:00:00 2001 From: Nathaniel Cook Date: Fri, 27 Jul 2018 09:15:28 -0600 Subject: [PATCH] fix: Panic in query/controller on Statistics --- query/control/controller.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/query/control/controller.go b/query/control/controller.go index 4c610b8a4c..5cdff02c1b 100644 --- a/query/control/controller.go +++ b/query/control/controller.go @@ -435,6 +435,9 @@ func (q *Query) Done() { // Statistics reports the statisitcs for the query. // The statisitcs are not complete until the query is finished. func (q *Query) Statistics() query.Statistics { + q.mu.Lock() + defer q.mu.Lock() + stats := query.Statistics{} stats.TotalDuration = q.parentSpan.Duration if q.compileSpan != nil { @@ -453,7 +456,9 @@ func (q *Query) Statistics() query.Statistics { stats.ExecuteDuration = q.executeSpan.Duration } stats.Concurrency = q.concurrency - stats.MaxAllocated = q.alloc.Max() + if q.alloc != nil { + stats.MaxAllocated = q.alloc.Max() + } return stats }