{"record":{"id":"4f80d442c80f04b1","repo":"thanos-io/thanos","slug":"open-temp-file","errorCode":null,"errorMessage":"open temp file","messagePattern":"open temp file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/block/indexheader/parallel_bucket.go","lineNumber":174,"sourceCode":"\t\tif err := os.MkdirAll(dir, os.ModePerm); err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"create temp dir\")\n\t\t}\n\t\tdf, err = fileutil.OpenDir(dir)\n\t}\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"open temp dir\")\n\t}\n\n\tif err := df.Sync(); err != nil {\n\t\treturn nil, errors.Wrap(err, \"sync dir\")\n\t}\n\n\tif err := os.RemoveAll(filename); err != nil {\n\t\treturn nil, errors.Wrap(err, \"remove existing file\")\n\t}\n\tf, err := os.OpenFile(filepath.Clean(filename), os.O_CREATE|os.O_RDWR, 0600)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"open temp file\")\n\t}\n\treturn &partFile{\n\t\tfile:       f,\n\t\tfileWriter: bufio.NewWriterSize(f, 32*1024),\n\t\tfileReader: bufio.NewReaderSize(f, 32*1024),\n\t}, nil\n}\n\nfunc (p *partFile) Close() error {\n\tif err := p.file.Close(); err != nil {\n\t\treturn err\n\t}\n\treturn os.Remove(p.file.Name())\n}\n\nfunc (p *partFile) Flush() error {\n\tif err := p.fileWriter.Flush(); err != nil {\n\t\treturn err","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/block/indexheader/parallel_bucket.go#L156-L192","documentation":"Wraps os.OpenFile in newPartFile when creating the part file for writing (O_CREATE|O_RDWR). It fires on permission or path problems after the old file was removed; without the part file the index-header part cannot be written or later read back.","triggerScenarios":"Thrown at pkg/block/indexheader/parallel_bucket.go:174 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check disk space and inode availability","Verify write permissions on the temp dir","Ensure the path is valid and not locked"],"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"}