{"record":{"id":"0ba42a2b69fb49b7","repo":"apache/dubbo","slug":"failed-to-release-cache-path-s-lock-file","errorCode":null,"errorMessage":"Failed to release cache path's lock file:{}","messagePattern":"Failed to release cache path's lock file:(.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/cache/FileCacheStore.java","lineNumber":108,"sourceCode":"        }\n        return properties;\n    }\n\n    private void unlock() {\n        if (directoryLock != null && directoryLock.isValid()) {\n            try {\n                directoryLock.release();\n                directoryLock.channel().close();\n                deleteFile(lockFile);\n            } catch (IOException e) {\n                logger.error(\n                        COMMON_CACHE_PATH_INACCESSIBLE,\n                        \"inaccessible of cache path\",\n                        \"\",\n                        \"Failed to release cache path's lock file:\" + lockFile,\n                        e);\n\n                throw new RuntimeException(\"Failed to release cache path's lock file:\" + lockFile, e);\n            }\n        }\n    }\n\n    public synchronized void refreshCache(Map<String, String> properties, String comment, long maxFileSize) {\n        if (CollectionUtils.isEmptyMap(properties)) {\n            return;\n        }\n\n        try (LimitedLengthBufferedWriter bw = new LimitedLengthBufferedWriter(\n                new OutputStreamWriter(new FileOutputStream(cacheFile, false), StandardCharsets.UTF_8), maxFileSize)) {\n\n            bw.write(\"#\" + comment);\n            bw.newLine();\n            bw.write(\"#\" + new Date());\n            bw.newLine();\n\n            for (Map.Entry<String, String> e : properties.entrySet()) {","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/cache/FileCacheStore.java#L90-L126","documentation":"Thrown by FileCacheStore.unlock() when releasing the FileLock, closing the channel, or deleting the lock file raises an IOException. The cache (e.g. service-name mapping or metadata cache) could not cleanly release its directory lock during shutdown/refresh, so the error is wrapped in a RuntimeException and propagated.","triggerScenarios":"FileCacheStore is being closed/refreshed and directoryLock.release(), channel().close(), or deleteFile(lockFile) throws IOException. Happens when the lock file was already deleted, the channel is already closed, or the filesystem rejects the operation.","commonSituations":"Running in a container (Docker/Kubernetes) with an ephemeral or read-only mounted volume where the cache directory lives. Multiple JVMs or a previous crashed Dubbo instance left the lock in an odd state. NFS or network filesystems that delay lock release.","solutions":["Ensure the cache directory (default ~/.dubbo) is writable and on a local, non-read-only filesystem.","Remove stale .lock files from the cache directory if no Dubbo instance is running.","If running in a container, mount a writable tmpfs or emptyDir for the cache path instead of a read-only volume.","Disable file cache (pass enableFileCache=false to FileCacheStoreFactory.getInstance) if the environment cannot guarantee lock semantics."],"exampleFix":"// before: cache on read-only mount\nFileCacheStoreFactory.getInstance(\"/readOnly/.dubbo\", \"meta\");\n// after: writable local path or disabled\nFileCacheStoreFactory.getInstance(null, \"meta\", false);","handlingStrategy":"try-catch","validationCode":"// Pre-check the cache directory is writable and lock is valid\nFile dir = new File(System.getProperty(\"user.home\"), \".dubbo\");\nif (!dir.canWrite()) {\n    // disable file cache or fix permissions before creating FileCacheStore\n}","typeGuard":null,"tryCatchPattern":"try {\n    cacheStore.close(); // or refreshCache\n} catch (RuntimeException e) {\n    if (e.getCause() instanceof IOException) {\n        // lock release failed; clear stale lock file and continue\n    }\n}","preventionTips":["Place the cache directory on a local writable filesystem.","Remove stale .lock files when no Dubbo instance is running.","In containers, use a writable volume for the cache path.","Consider enableFileCache=false if lock semantics are unreliable."],"tags":["cache","file-io","file-lock","filesystem","shutdown"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}