{"record":{"id":"eb4bcaff9916cc57","repo":"thanos-io/thanos","slug":"get-appender-eb4bca","errorCode":null,"errorMessage":"get appender","messagePattern":"get appender","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/receive/writer.go","lineNumber":87,"sourceCode":"\t\tmultiTSDB: multiTSDB,\n\t\topts:      opts,\n\t}\n}\n\nfunc (r *Writer) Write(ctx context.Context, tenantID string, wreq []prompb.TimeSeries) error {\n\ttLogger := log.With(r.logger, \"tenant\", tenantID)\n\n\ts, err := r.multiTSDB.TenantAppendable(tenantID)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"get tenant appendable\")\n\t}\n\n\tapp, err := s.Appender(ctx)\n\tif err == tsdb.ErrNotReady {\n\t\treturn err\n\t}\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"get appender\")\n\t}\n\tgetRef := app.(storage.GetRef)\n\tvar (\n\t\tref          storage.SeriesRef\n\t\terrorTracker writeErrorTracker\n\t)\n\tapp = &ReceiveAppender{\n\t\ttLogger:        tLogger,\n\t\ttooFarInFuture: r.opts.TooFarInFutureTimeWindow,\n\t\tAppender:       app,\n\t}\n\n\tfor _, t := range wreq {\n\t\t// Check if time series labels are valid. If not, skip the time series\n\t\t// and report the error.\n\t\tif err := labelpb.ValidateLabels(t.Labels); err != nil {\n\t\t\tlset := &labelpb.ZLabelSet{Labels: t.Labels}\n\t\t\terrorTracker.addLabelsError(err, lset, tLogger)","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/receive/writer.go#L69-L105","documentation":"Error from Writer.Write when s.Appender(ctx) fails for any reason other than tsdb.ErrNotReady (which is returned unwrapped). It wraps the underlying storage error encountered while opening an appender for the tenant's TSDB.","triggerScenarios":"TenantAppendable succeeded but the tenant TSDB's Appender(ctx) call returned a non-ErrNotReady error - e.g. head block corrupted, storage closed, or context cancelled during appender creation.","commonSituations":"TSDB shutting down or reloading while writes arrive; corrupted head data on disk; request context cancelled by an upstream timeout; OOM-related head failures.","solutions":["Inspect the wrapped cause; if it is context.Canceled/deadline, check upstream timeouts and receiver load.","If tsdb.ErrNotReady, note that code path returns it unwrapped - so a wrapped error here means a different storage problem; check receiver logs for head corruption.","Restart/recover the receive pod if the TSDB head is in a bad state; restore from backup if corruption persists.","Ensure the receiver has finished startup (TSDB ready) before routing traffic."],"exampleFix":"// caller handling\nif err := writer.Write(ctx, tenant, req); err != nil {\n    if errors.Is(err, context.DeadlineExceeded) {\n        // retry with backoff\n    } else { /* surface to sender as 500 */ }\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := writer.Write(ctx, tenant, series); err != nil {\n    if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {\n        // retry with backoff and a fresh context\n    }\n    // otherwise surface as 500 to sender\n}","preventionTips":["Set generous but bounded context deadlines for writes","Confirm receiver readiness (TSDB opened) before accepting traffic","Monitor receiver disk/memory health"],"tags":["thanos","receive","tsdb","storage","go"],"backgroundTag":"database-write-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"}