{"record":{"id":"15315a676b64bc47","repo":"hyperledger/fabric","slug":"error-cleaning-up-transient-files","errorCode":null,"errorMessage":"error cleaning up transient files","messagePattern":"error cleaning up transient files","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"orderer/common/filerepo/filerepo.go","lineNumber":65,"sourceCode":"\tif err := fileutil.SyncDir(repoParentDir); err != nil {\n\t\treturn nil, err\n\t}\n\n\tfiles, err := os.ReadDir(fileRepoDir)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Remove existing transient files in the repo\n\ttransientFilePattern := \"*\" + fileSuffix + defaultTransientFileMarker\n\tfor _, f := range files {\n\t\tisTransientFile, err := filepath.Match(transientFilePattern, f.Name())\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif isTransientFile {\n\t\t\tif err := os.Remove(filepath.Join(fileRepoDir, f.Name())); err != nil {\n\t\t\t\treturn nil, errors.Wrapf(err, \"error cleaning up transient files\")\n\t\t\t}\n\t\t}\n\t}\n\n\tif err := fileutil.SyncDir(fileRepoDir); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn &Repo{\n\t\ttransientFileMarker: defaultTransientFileMarker,\n\t\tfileSuffix:          fileSuffix,\n\t\tfileRepoDir:         fileRepoDir,\n\t}, nil\n}\n\n// Save atomically persists the content to suffix/baseName+suffix file by first writing it\n// to a tmp file marked by the transientFileMarker and then moves the file to the final\n// destination indicated by the FileSuffix.","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/orderer/common/filerepo/filerepo.go#L47-L83","documentation":"filerepo.New scans the repository directory and removes leftover transient (temp) files from prior interrupted operations. If os.Remove fails on such a file, the directory cannot be prepared and New returns this wrapped error, aborting repo creation. It indicates filesystem-level trouble removing a *.tmp file.","triggerScenarios":"Creating a Repo (e.g. via New in serve) when the repo directory contains a file matching the transient pattern that cannot be deleted: read-only filesystem, permissions missing on the file or directory, or the file is held open by another process.","commonSituations":"Orderer runs as non-root but owns files from a prior run as root (or vice versa); read-only or full disk mounts; stale temp files locked by a concurrently running orderer on the same data directory.","solutions":["Check permissions on the file repo directory and its *.tmp files and remove them manually with sufficient privileges","Verify the orderer process is the only one using the data directory and stop any duplicate process","Ensure the filesystem (e.g. Docker volume/host mount) is writable, not read-only, and has free space","Re-run the orderer; if the volume persists across restarts, fix ownership (chown) to the user the orderer runs as"],"exampleFix":"// before (orderer cannot delete transient file)\nos.Remove(filepath.Join(fileRepoDir, f.Name())) // permission denied\n// after (shell, as the operator)\nsudo chown -R orderer:orderer /var/hyperledger/production/orderer\nrm -f /var/hyperledger/production/orderer/*/*.tmp","handlingStrategy":"validation","validationCode":"dir := \"/var/hyperledger/production/orderer\"\ninfo, err := os.Stat(dir)\nif err != nil || !info.IsDir() {\n    panic(\"file repo dir missing\")\n}\nif err := unix.Access(dir, unix.W_OK); err != nil {\n    panic(\"file repo dir not writable by current user\")\n}\nmatches, _ := filepath.Glob(filepath.Join(dir, \"*\", \"*.tmp\"))\nfor _, m := range matches {\n    if err := os.Remove(m); err != nil {\n        panic(\"cannot remove transient file: \" + m)\n    }\n}","typeGuard":null,"tryCatchPattern":"repo, err := filerepo.New(dir, suffix)\nif err != nil {\n    if strings.Contains(err.Error(), \"error cleaning up transient files\") {\n        logger.Fatalf(\"stale transient files not removable, check permissions on %s: %v\", dir, err)\n    }\n    return err\n}","preventionTips":["Run the orderer with a consistent, dedicated user across restarts","Ensure data volumes are writable and not read-only mounts","Avoid running two orderer processes against the same data directory","Pre-clean *.tmp files during maintenance windows"],"tags":["filesystem","permissions","startup"],"backgroundTag":"file-permission-denied","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}