From 1286cead759903084fd9f4c25051c3e995f8bbbb Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 26 Feb 2020 21:17:35 +0200 Subject: [PATCH] app/vminsert: properly initialize InsertCtx This should prevent from panic described at https://github.com/VictoriaMetrics/VictoriaMetrics/issues/339 --- app/vminsert/graphite/request_handler.go | 1 + app/vminsert/influx/request_handler.go | 1 + app/vminsert/opentsdb/request_handler.go | 1 + app/vminsert/opentsdbhttp/request_handler.go | 1 + app/vminsert/promremotewrite/request_handler.go | 1 + app/vminsert/vmimport/request_handler.go | 1 + 6 files changed, 6 insertions(+) diff --git a/app/vminsert/graphite/request_handler.go b/app/vminsert/graphite/request_handler.go index 73f373a60..14a557fba 100644 --- a/app/vminsert/graphite/request_handler.go +++ b/app/vminsert/graphite/request_handler.go @@ -32,6 +32,7 @@ func insertRows(at *auth.Token, rows []parser.Row) error { ctx := netstorage.GetInsertCtx() defer netstorage.PutInsertCtx(ctx) + ctx.Reset() // This line is required for initializing ctx internals. atCopy := *at for i := range rows { r := &rows[i] diff --git a/app/vminsert/influx/request_handler.go b/app/vminsert/influx/request_handler.go index a44dff13e..d6ae61bec 100644 --- a/app/vminsert/influx/request_handler.go +++ b/app/vminsert/influx/request_handler.go @@ -59,6 +59,7 @@ func insertRows(at *auth.Token, db string, rows []parser.Row) error { defer putPushCtx(ctx) ic := &ctx.Common + ic.Reset() // This line is required for initializing ic internals. rowsTotal := 0 for i := range rows { r := &rows[i] diff --git a/app/vminsert/opentsdb/request_handler.go b/app/vminsert/opentsdb/request_handler.go index c7125211d..8d4ce0ba2 100644 --- a/app/vminsert/opentsdb/request_handler.go +++ b/app/vminsert/opentsdb/request_handler.go @@ -32,6 +32,7 @@ func insertRows(at *auth.Token, rows []parser.Row) error { ctx := netstorage.GetInsertCtx() defer netstorage.PutInsertCtx(ctx) + ctx.Reset() // This line is required for initializing ctx internals. atCopy := *at for i := range rows { r := &rows[i] diff --git a/app/vminsert/opentsdbhttp/request_handler.go b/app/vminsert/opentsdbhttp/request_handler.go index 039db953d..4dccbe529 100644 --- a/app/vminsert/opentsdbhttp/request_handler.go +++ b/app/vminsert/opentsdbhttp/request_handler.go @@ -50,6 +50,7 @@ func insertRows(at *auth.Token, rows []parser.Row) error { ctx := netstorage.GetInsertCtx() defer netstorage.PutInsertCtx(ctx) + ctx.Reset() // This line is required for initializing ctx internals. for i := range rows { r := &rows[i] ctx.Labels = ctx.Labels[:0] diff --git a/app/vminsert/promremotewrite/request_handler.go b/app/vminsert/promremotewrite/request_handler.go index 8b0b5e58f..04e29acfb 100644 --- a/app/vminsert/promremotewrite/request_handler.go +++ b/app/vminsert/promremotewrite/request_handler.go @@ -31,6 +31,7 @@ func insertRows(at *auth.Token, timeseries []prompb.TimeSeries) error { ctx := netstorage.GetInsertCtx() defer netstorage.PutInsertCtx(ctx) + ctx.Reset() // This line is required for initializing ctx internals. rowsTotal := 0 for i := range timeseries { ts := ×eries[i] diff --git a/app/vminsert/vmimport/request_handler.go b/app/vminsert/vmimport/request_handler.go index c563be5c0..377f22979 100644 --- a/app/vminsert/vmimport/request_handler.go +++ b/app/vminsert/vmimport/request_handler.go @@ -32,6 +32,7 @@ func insertRows(at *auth.Token, rows []parser.Row) error { ctx := netstorage.GetInsertCtx() defer netstorage.PutInsertCtx(ctx) + ctx.Reset() // This line is required for initializing ctx internals. rowsTotal := 0 for i := range rows { r := &rows[i]