{"record":{"id":"75b7d58509a19762","repo":"thanos-io/thanos","slug":"new-symbols","errorCode":null,"errorMessage":"new symbols","messagePattern":"new symbols","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/receive/writecapnp/marshal.go","lineNumber":133,"sourceCode":"\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\tsymbols, err := wr.NewSymbols()\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"new symbols\")\n\t}\n\tif err := marshalSymbols(builder, symbols); err != nil {\n\t\treturn errors.Wrap(err, \"marshal symbols\")\n\t}\n\treturn nil\n}\n\nfunc marshalSymbols(builder *symboltable.Builder, symbols Symbols) error {\n\toffsets, err := symbols.NewOffsets(builder.Len())\n\tif err != nil {\n\t\treturn err\n\t}\n\tdata := make([]byte, builder.SymbolsSize)\n\tfor k, entry := range builder.Table {\n\t\tend := entry.Start + uint32(len(k))\n\t\tcopy(data[entry.Start:end], k)\n\t\toffsets.Set(int(entry.Index), end)\n\t}","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/receive/writecapnp/marshal.go#L115-L151","documentation":"Wrap of the capnp error from wr.NewSymbols(), which allocates the symbol-list field on the WriteRequest message in BuildIntoSingleTenantWriteRequest. It means capnp could not create the symbols list on the message; the raw capnp cause is wrapped underneath.","triggerScenarios":"BuildIntoSingleTenantWriteRequest reaching the symbols step after all series were marshaled, and the capnp message cannot allocate the new symbols list (arena exhausted, message finalized/already marshaled).","commonSituations":"Reusing a WriteRequest whose message was already marshaled or came from a read-only view; extremely large write requests consuming the whole segment before the symbols step.","solutions":["Always create the WriteRequest from a fresh capnp.NewMessage(SingleSegment(nil)) before calling this function; never reuse a marshaled message.","Reduce request size so allocation fits the arena.","Check the wrapped capnp error for the precise failure.","Upgrade capnp library if hitting a known allocation bug."],"exampleFix":"// before: reusing wr across calls\nwr := previouslyMarshaledWriteRequest\nBuildIntoSingleTenantWriteRequest(wr, tenant, series)\n// after: fresh message each time\n_, seg, _ := capnp.NewMessage(capnp.SingleSegment(nil))\nwr, _ := NewRootWriteRequest(seg)\nBuildIntoSingleTenantWriteRequest(wr, tenant, series)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := BuildIntoSingleTenantWriteRequest(wr, tenant, series); err != nil {\n    if strings.Contains(err.Error(), \"new symbols\") {\n        // rebuild wr from a fresh capnp.NewMessage arena and retry once\n    }\n}","preventionTips":["Never reuse a capnp message after Marshal","Always construct WriteRequest via Build/NewRootWriteRequest on a fresh arena","Keep request sizes bounded"],"tags":["capnp","serialization","symbol-table","go"],"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"}