From 0b87f0260246c07c81deda71b5a115fd182cae96 Mon Sep 17 00:00:00 2001 From: Nikolay Date: Thu, 24 Dec 2020 10:01:40 +0300 Subject: [PATCH] fixes panic (#979) * fixes panic https://github.com/VictoriaMetrics/helm-charts/issues/89 * add fast-path * Apply suggestions from code review Co-authored-by: Aliaksandr Valialkin --- app/vmselect/prometheus/prometheus.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/vmselect/prometheus/prometheus.go b/app/vmselect/prometheus/prometheus.go index f504f72f0b..c7c6f6aaa6 100644 --- a/app/vmselect/prometheus/prometheus.go +++ b/app/vmselect/prometheus/prometheus.go @@ -500,8 +500,15 @@ func DeleteHandler(startTime time.Time, at *auth.Token, r *http.Request) error { var deleteDuration = metrics.NewSummary(`vm_request_duration_seconds{path="/api/v1/admin/tsdb/delete_series"}`) func resetRollupResultCaches() { + resetRollupResultCacheCalls.Inc() + // Reset local cache before checking whether selectNodes list is empty. + // This guarantees that at least local cache is reset if selectNodes list is empty. + promql.ResetRollupResultCache() if len(*selectNodes) == 0 { - logger.Panicf("BUG: missing -selectNode flag") + logger.Warnf("missing -selectNode flag, cache reset request wont be propagated to the other vmselect nodes." + + "This can be fixed by enumerating all the vmselect node addresses in `-selectNode` command line flag. " + + " For example: -selectNode=select-addr-1:8481,select-addr-2:8481") + return } for _, selectNode := range *selectNodes { callURL := fmt.Sprintf("http://%s/internal/resetRollupResultCache", selectNode) @@ -519,7 +526,6 @@ func resetRollupResultCaches() { } _ = resp.Body.Close() } - resetRollupResultCacheCalls.Inc() } var (