{"record":{"id":"8283ea875548edaa","repo":"juicedata/juicefs","slug":"write-lock-file-s-w","errorCode":null,"errorMessage":"write lock file %s: %w","messagePattern":"write lock file (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/chunk/disk_cache.go","lineNumber":208,"sourceCode":"func (cache *diskCache) createLockFile() {\n\tlockfile := cache.lockFilePath()\n\terr := cache.checkErr(func() error {\n\t\tf, err := os.OpenFile(lockfile, os.O_CREATE|os.O_RDWR, 0666)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"open lock file %s: %w\", lockfile, err)\n\t\t}\n\t\tdefer f.Close()\n\t\trawId, err := io.ReadAll(f)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"read lock file %s: %w\", lockfile, err)\n\t\t}\n\t\tif len(rawId) > 0 {\n\t\t\tcache.id = string(rawId)\n\t\t} else {\n\t\t\tcache.id = uuid.New().String()\n\t\t\t_, err = f.Write([]byte(cache.id))\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"write lock file %s: %w\", lockfile, err)\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t})\n\tif err != nil {\n\t\tlogger.Warnf(\"create lock file %s: %s\", lockfile, err)\n\t}\n}\n\nfunc (cache *diskCache) checkLockFile() {\n\tlockfile := cache.lockFilePath()\n\tfor cache.available() {\n\t\ttime.Sleep(time.Second * 10)\n\t\tif err := cache.statFile(lockfile); err != nil && os.IsNotExist(err) {\n\t\t\tlogger.Infof(\"lockfile %s is lost, cache device maybe broken\", lockfile)\n\t\t\tif inRootVolume(cache.dir) && cache.freeRatio < 0.2 {\n\t\t\t\tlogger.Infof(\"cache directory %s is in root volume, keep 20%% space free\", cache.dir)\n\t\t\t\tcache.freeRatio = 0.2","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/chunk/disk_cache.go#L190-L226","documentation":"Reported by diskCache.createLockFile when a new cache instance UUID cannot be persisted to the empty .lock file. The cache id would change across restarts, so the directory is marked problematic rather than silently reused.","triggerScenarios":"Thrown at pkg/chunk/disk_cache.go:208 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the cache directory is writable and the filesystem is healthy"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}