{"record":{"id":"5eb786db4302022b","repo":"thanos-io/thanos","slug":"open-temp-dir","errorCode":null,"errorMessage":"open temp dir","messagePattern":"open temp dir","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/block/indexheader/parallel_bucket.go","lineNumber":162,"sourceCode":"\n// partFile stores parts in temporary files.\ntype partFile struct {\n\tfile       *os.File\n\tfileWriter *bufio.Writer\n\tfileReader *bufio.Reader\n}\n\nfunc newPartFile(filename string) (*partFile, error) {\n\tdir := filepath.Dir(filename)\n\tdf, err := fileutil.OpenDir(dir)\n\tif os.IsNotExist(err) {\n\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","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/block/indexheader/parallel_bucket.go#L144-L180","documentation":"Wraps fileutil.OpenDir in newPartFile when opening the directory that will hold an index-header part file. It fires when the dir cannot be opened for reasons other than non-existence (permissions, symlink loop, I/O error); note the second OpenDir after MkdirAll also funnels its error here.","triggerScenarios":"Thrown at pkg/block/indexheader/parallel_bucket.go:162 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the directory exists and is accessible","Check mount health and permissions","Retry after fixing filesystem state"],"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"}