{"record":{"id":"a9c390007747402a","repo":"juicedata/juicefs","slug":"read-lock-file-s-w","errorCode":null,"errorMessage":"read lock file %s: %w","messagePattern":"read lock file (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/chunk/disk_cache.go","lineNumber":200,"sourceCode":"\t\tlogger.Infof(\"Adjusted max items based on freeratio: from %d to %s items\", limit, maxItems)\n\t}\n}\n\nfunc (cache *diskCache) lockFilePath() string {\n\treturn filepath.Join(cache.dir, \".lock\")\n}\n\nfunc (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() {","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/chunk/disk_cache.go#L182-L218","documentation":"Reported by diskCache.createLockFile when the existing .lock file in the cache directory cannot be read to recover the cache instance id. An I/O error (not a missing file) means the lock state is unreadable and the cache dir is treated as problematic.","triggerScenarios":"Thrown at pkg/chunk/disk_cache.go:200 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix disk/permission issues on the cache directory","Delete the unreadable .lock file to let the cache regenerate its id"],"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"}