{"record":{"id":"1f48204a9f2febd1","repo":"thanos-io/thanos","slug":"open-index-writer","errorCode":null,"errorMessage":"open index writer","messagePattern":"open index writer","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/block/index.go","lineNumber":460,"sourceCode":"\tdefer runutil.CloseWithErrCapture(&err, indexr, \"repair index reader\")\n\n\tchunkr, err := b.Chunks()\n\tif err != nil {\n\t\treturn resid, errors.Wrap(err, \"open chunks\")\n\t}\n\tdefer runutil.CloseWithErrCapture(&err, chunkr, \"repair chunk reader\")\n\n\tresdir := filepath.Join(dir, resid.String())\n\n\tchunkw, err := chunks.NewWriter(filepath.Join(resdir, ChunksDirname))\n\tif err != nil {\n\t\treturn resid, errors.Wrap(err, \"open chunk writer\")\n\t}\n\tdefer runutil.CloseWithErrCapture(&err, chunkw, \"repair chunk writer\")\n\n\tindexw, err := index.NewWriter(context.TODO(), filepath.Join(resdir, IndexFilename))\n\tif err != nil {\n\t\treturn resid, errors.Wrap(err, \"open index writer\")\n\t}\n\tdefer runutil.CloseWithErrCapture(&err, indexw, \"repair index writer\")\n\n\t// TODO(fabxc): adapt so we properly handle the version once we update to an upstream\n\t// that has multiple.\n\tresmeta := *meta\n\tresmeta.ULID = resid\n\tresmeta.Stats = tsdb.BlockStats{} // Reset stats.\n\tresmeta.Thanos.Source = source    // Update source.\n\n\tif err := rewrite(ctx, logger, indexr, chunkr, indexw, chunkw, &resmeta, ignoreChkFns); err != nil {\n\t\treturn resid, errors.Wrap(err, \"rewrite block\")\n\t}\n\tresmeta.Thanos.SegmentFiles = GetSegmentFiles(resdir)\n\tif err := resmeta.WriteToDir(logger, resdir); err != nil {\n\t\treturn resid, err\n\t}\n\t// TSDB may rewrite metadata in bdir.","sourceCodeStart":442,"sourceCodeEnd":478,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/block/index.go#L442-L478","documentation":"Wraps tsdb index.NewWriter while creating the index file for the repaired block in Repair. It fires when the new index header/symbol table cannot be initialized on disk in the result directory, aborting the index repair workflow.","triggerScenarios":"Thrown at pkg/block/index.go:460 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check disk space and permissions on the repair output dir","Ensure the result dir is writable and not locked","Retry repair after fixing filesystem issues"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}