{"record":{"id":"8cfdad3655fd01b5","repo":"thanos-io/thanos","slug":"new-labels","errorCode":null,"errorMessage":"new labels","messagePattern":"new labels","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/receive/writecapnp/marshal.go","lineNumber":81,"sourceCode":"\t}\n\treturn wr, nil\n}\n\nfunc BuildInto(wr *TimeSeriesTenantTuple, tenant string, tsreq []prompb.TimeSeries, builder *symboltable.Builder) error {\n\tif err := wr.SetTenant(tenant); err != nil {\n\t\treturn errors.Wrap(err, \"set tenant\")\n\t}\n\n\tseries, err := wr.NewTimeSeries(int32(len(tsreq)))\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor i, ts := range tsreq {\n\t\ttsc := series.At(i)\n\n\t\tlblsc, err := tsc.NewLabels(int32(len(ts.Labels)))\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"new labels\")\n\t\t}\n\t\tif err := marshalLabels(lblsc, ts.Labels, builder); err != nil {\n\t\t\treturn errors.Wrap(err, \"marshal labels\")\n\t\t}\n\t\tif err := marshalSamples(tsc, ts.Samples); err != nil {\n\t\t\treturn errors.Wrap(err, \"marshal samples\")\n\t\t}\n\t\tif err := marshalHistograms(tsc, ts.Histograms); err != nil {\n\t\t\treturn errors.Wrap(err, \"marshal histograms\")\n\t\t}\n\t\tif err := marshalExemplars(tsc, ts.Exemplars, builder); err != nil {\n\t\t\treturn errors.Wrap(err, \"marshal exemplars\")\n\t\t}\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/receive/writecapnp/marshal.go#L63-L99","documentation":"Inside BuildInto, for each incoming prometheus TimeSeries, tsc.NewLabels(n) allocates a capnp list of n Label entries. When capnp cannot allocate that list in the message arena, the error is wrapped as 'new labels'.","triggerScenarios":"A time series with a very large number of labels, or a batch so large the capnp arena/segment limit is exhausted while allocating the label list for series index i.","commonSituations":"Users scraping targets with hundreds of labels; huge WriteRequest batches exceeding capnp message size limits; memory pressure on the sender.","solutions":["Split the WriteRequest into smaller batches before calling BuildInto","Drop or normalize labels with very high cardinality (e.g. via relabeling)","Increase the capnp message size limit/arena if the library exposes it","Check for capnp library version notes on list allocation limits"],"exampleFix":"// before\nerr := BuildInto(tuple, tenant, allSeries, builder)\n// after\nfor chunk := range slices.Chunk(allSeries, 1000) {\n    if err := BuildInto(tuple, tenant, chunk, builder); err != nil {\n        return err\n    }\n}","handlingStrategy":"validation","validationCode":"func maxLabelCount(series []prompb.TimeSeries) int {\n    m := 0\n    for _, ts := range series { if len(ts.Labels) > m { m = len(ts.Labels) } }\n    return m\n}\n// call BuildInto only if maxLabelCount(tsreq) <= 128","typeGuard":null,"tryCatchPattern":"if err := BuildInto(tuple, tenant, tsreq, builder); err != nil && strings.Contains(err.Error(), \"new labels\") {\n    // split the batch in half and retry each half\n    return splitAndRetry(tsreq)\n}","preventionTips":["Cap per-series label count via relabeling","Bound WriteRequest batch size","Watch memory/arena usage on large sends"],"tags":["capnp","serialization","memory","allocation"],"backgroundTag":"schema-validation-failed","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}