app/vminsert: properly initialize InsertCtx

This should prevent from panic described at https://github.com/VictoriaMetrics/VictoriaMetrics/issues/339
This commit is contained in:
Aliaksandr Valialkin 2020-02-26 21:17:35 +02:00
parent 0597f1e39a
commit 1286cead75
6 changed files with 6 additions and 0 deletions

View File

@ -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]

View File

@ -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]

View File

@ -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]

View File

@ -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]

View File

@ -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 := &timeseries[i]

View File

@ -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]