{"record":{"id":"aee1dd1709fcd8d3","repo":"juicedata/juicefs","slug":"open-lock-file-s-w","errorCode":null,"errorMessage":"open lock file %s: %w","messagePattern":"open lock file (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/chunk/disk_cache.go","lineNumber":195,"sourceCode":"\n\t\tmaxItems := \"unlimited\"\n\t\tif cache.maxItems != 0 {\n\t\t\tmaxItems = strconv.FormatInt(cache.maxItems, 10)\n\t\t}\n\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 {","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/chunk/disk_cache.go#L177-L213","documentation":"Reported by diskCache.createLockFile when the .lock file inside a cache directory cannot be opened. The error is recorded via checkErr; the cache dir typically gets rotated into a problematic state until the underlying permission or path issue is fixed.","triggerScenarios":"Thrown at pkg/chunk/disk_cache.go:195 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check ownership and write permissions of the cache directory","Remove a stale/corrupt .lock file if present so it can be recreated"],"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"}