{"record":{"id":"003668c6d1d9f17b","repo":"juicedata/juicefs","slug":"cannot-disable-dir-stats-when-there-are-still-d-d","errorCode":null,"errorMessage":"cannot disable dir stats when there are still %d dir quotas: %v","messagePattern":"cannot disable dir stats when there are still (.+?) dir quotas: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/config.go","lineNumber":489,"sourceCode":"\t\t}\n\t\tif trash && format.TrashDays == 0 {\n\t\t\twarn(\"The current trash will be emptied and future removed files will purged immediately.\")\n\t\t\tif !yes && !userConfirmed() {\n\t\t\t\treturn fmt.Errorf(\"Aborted.\")\n\t\t\t}\n\t\t}\n\t\tif originDirStats && !format.DirStats {\n\t\t\tqs := make(map[string]*meta.Quota)\n\t\t\terr := m.HandleQuota(meta.Background(), meta.QuotaList, \"\", meta.DirQuotaType, qs, false, false, false)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrap(err, \"list quotas\")\n\t\t\t}\n\t\t\tif len(qs) != 0 {\n\t\t\t\tpaths := make([]string, 0, len(qs))\n\t\t\t\tfor path := range qs {\n\t\t\t\t\tpaths = append(paths, path)\n\t\t\t\t}\n\t\t\t\treturn fmt.Errorf(\"cannot disable dir stats when there are still %d dir quotas: %v\", len(qs), paths)\n\t\t\t}\n\t\t}\n\t\tif clientVer {\n\t\t\tconfirmClientVer := false\n\t\t\tif format.CheckVersion() != nil {\n\t\t\t\twarn(\"Clients below version %s will be rejected after modification.\", format.MinClientVersion)\n\t\t\t\tconfirmClientVer = true\n\t\t\t}\n\n\t\t\t// check all clients\n\t\t\tif sessions, err := m.ListSessions(); err == nil {\n\t\t\t\twarnMsg := \"\"\n\t\t\t\tfor _, session := range sessions {\n\t\t\t\t\tif err := format.CheckCliVersion(version.Parse(session.Version)); err != nil {\n\t\t\t\t\t\twarnMsg += fmt.Sprintf(\"host %s pid %d client version error: %s\\n\", session.HostName, session.ProcessID, err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif warnMsg != \"\" {","sourceCodeStart":471,"sourceCodeEnd":507,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/config.go#L471-L507","documentation":"`juicefs config` refuses to disable directory-level stats (`--stats=false`) while the volume still has directory quotas defined. Dir stats are the accounting backbone for dir quotas, so the command fails fast instead of silently breaking quota usage tracking. The error lists how many quotas remain and their paths.","triggerScenarios":"Running `juicefs config <META> --stats=false` when `HandleQuota(QuotaList, DirQuotaType)` returns one or more existing dir quotas, without `--force`.","commonSituations":"Operators set per-directory quotas (e.g. `juicefs quota set /mnt/jfs/subdir --capacity ...`) and later try to turn off dir stats for performance, forgetting the quotas still depend on it.","solutions":["Delete the remaining dir quotas first with `juicefs quota remove <path>` for each listed path, then disable dir stats.","Re-enable dir stats if quotas are still needed (they cannot work without stats).","Use `--force` to skip the safety check only if you accept that quota usage reporting will be broken."],"exampleFix":"// before\njuicefs config sqlite3://test.db --stats=false\n// error: cannot disable dir stats when there are still 2 dir quotas: [/a /b]\n// after\njuicefs quota remove /mnt/jfs/a && juicefs quota remove /mnt/jfs/b\njuicefs config sqlite3://test.db --stats=false","handlingStrategy":"validation","validationCode":"quotas=$(juicefs quota list $META 2>/dev/null | wc -l)\nif [ \"$quotas\" -gt 0 ]; then\n  echo \"Remove dir quotas before disabling stats\"\n  exit 1\nfi\njuicefs config $META --stats=false","typeGuard":null,"tryCatchPattern":null,"preventionTips":["List dir quotas with `juicefs quota list` before toggling dir stats.","Treat dir stats as a prerequisite of dir quotas; never disable them while quotas exist.","Use `--force` consciously and document the tradeoff in runbooks."],"tags":["cli","quota","config"],"backgroundTag":"invalid-state-transition","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"}