{"record":{"id":"f8b2eee994c942d2","repo":"alibaba/spring-ai-alibaba","slug":"failed-to-clear-file-system-store","errorCode":null,"errorMessage":"Failed to clear file system store","messagePattern":"Failed to clear file system store","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/store/stores/FileSystemStore.java","lineNumber":220,"sourceCode":"\t\t\tint endIndex = Math.min(offset + limit, namespaces.size());\n\t\t\treturn namespaces.subList(offset, endIndex);\n\t\t}\n\t\tfinally {\n\t\t\tlock.readLock().unlock();\n\t\t}\n\t}\n\n\t@Override\n\tpublic void clear() {\n\t\tlock.writeLock().lock();\n\t\ttry {\n\t\t\tif (Files.exists(rootPath)) {\n\t\t\t\tdeleteDirectoryRecursively(rootPath);\n\t\t\t}\n\t\t\tinitializeRootDirectory();\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tthrow new RuntimeException(\"Failed to clear file system store\", e);\n\t\t}\n\t\tfinally {\n\t\t\tlock.writeLock().unlock();\n\t\t}\n\t}\n\n\t@Override\n\tpublic long size() {\n\t\treturn getAllItems().size();\n\t}\n\n\t@Override\n\tpublic boolean isEmpty() {\n\t\treturn size() == 0;\n\t}\n\n\t/**\n\t * Initialize root directory.","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/store/stores/FileSystemStore.java#L202-L238","documentation":"FileSystemStore.clear removes the entire root directory recursively and re-creates it; any exception in that process is wrapped in RuntimeException('Failed to clear file system store'). It runs under the store write lock, so a failure leaves the store unchanged but propagates to the caller.","triggerScenarios":"store.clear() is called and deleteDirectoryRecursively(rootPath) or Files.exists/initializeRootDirectory throws IOException — e.g. a file under root cannot be deleted, or the root cannot be recreated after deletion.","commonSituations":"Clearing a store mounted on a read-only or full disk; permission mismatch after the root dir was created by another user; NFS/Windows locking a file during recursive delete.","solutions":["Check the wrapped cause for the specific file that failed to delete","Verify the process has delete permissions on every entry under the store root","Manually remove leftover files then retry clear()","Move the store root to a local writable filesystem"],"exampleFix":"// before\nstore.clear();\n// after\ntry {\n    store.clear();\n} catch (RuntimeException e) {\n    log.error(\"store clear failed: {}\", e.getCause().getMessage());\n}","handlingStrategy":"try-catch","validationCode":"if (!Files.isWritable(Path.of(storeRoot))) {\n    throw new IllegalStateException(\"store root not writable, clear() will fail\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    store.clear();\n} catch (RuntimeException e) {\n    logger.error(\"clear failed: {}\", e.getCause());\n    // leave store intact, alert operator\n}","preventionTips":["Never mount the store root read-only if clear() is used","Avoid clearing while other processes hold files open","Schedule clears during maintenance windows"],"tags":["filesystem","io","store"],"backgroundTag":"file-delete-failed","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}