{"record":{"id":"ce0a2a072c13d792","repo":"juicedata/juicefs","slug":"quota-of-s-is-inconsistent-please-repair-it-with","errorCode":null,"errorMessage":"quota of %s is inconsistent, please repair it with --repair flag","messagePattern":"quota of (.+?) is inconsistent, please repair it with --repair flag","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/quota.go","lineNumber":975,"sourceCode":"\t\thumanize.Comma(q.UsedInodes), humanize.IBytes(uint64(q.UsedSpace)),\n\t\thumanize.Comma(usedInodes), humanize.IBytes(uint64(usedSpace)),\n\t)\n\n\tif repair {\n\t\tq.UsedInodes = usedInodes\n\t\tq.UsedSpace = usedSpace\n\t\tquotas[dpath] = q\n\t\tlogger.Info(\"repairing...\")\n\t\t_, err = m.en.doSetQuota(ctx, qtype, key, &Quota{\n\t\t\tMaxInodes:  -1,\n\t\t\tMaxSpace:   -1,\n\t\t\tUsedInodes: q.UsedInodes,\n\t\t\tUsedSpace:  q.UsedSpace,\n\t\t})\n\t\treturn err\n\t}\n\n\treturn fmt.Errorf(\"quota of %s is inconsistent, please repair it with --repair flag\", dpath)\n}\n\nfunc (m *baseMeta) compareUGUsage(usageMap map[uint64]*Summary, quotaMap map[uint64]*Quota, qtype uint32, retQuotas map[string]*Quota) bool {\n\tvar hasErr bool\n\tidType := \"uid\"\n\tif qtype == GroupQuotaType {\n\t\tidType = \"gid\"\n\t}\n\tfor id, usage := range usageMap {\n\t\tusedSpace := int64(usage.Size)\n\t\tusedInodes := int64(usage.Files)\n\t\tq, ok := quotaMap[id]\n\t\tif !ok {\n\t\t\tlogger.Warnf(\"%s:%d: quota not found, actual usage(%s, %s)\",\n\t\t\t\tidType, id, humanize.Comma(usedInodes), humanize.IBytes(uint64(usedSpace)))\n\t\t\thasErr = true\n\t\t\tcontinue\n\t\t}","sourceCodeStart":957,"sourceCodeEnd":993,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/quota.go#L957-L993","documentation":"Raised by baseMeta.checkDirUsage (pkg/meta/quota.go:975) when the quota record's stored usage (UsedInodes/UsedSpace) differs from the live summary computed by GetSummary, and the check was run without --repair. It is a consistency-check failure: the metadata engine's cached quota usage has drifted from actual filesystem contents.","triggerScenarios":"`juicefs quota check <path>` (without --repair) where q.UsedInodes != sum-based usedInodes or q.UsedSpace != usedSpace, e.g. after crashes, rollback of metadata, or bugs that missed quota accounting updates.","commonSituations":"Metadata engine restored from an old backup; a crash between data write and quota update; clients running older versions that mishandled quota increments; deleted files not decrementing usage due to a bug.","solutions":["Re-run with the --repair flag: `juicefs quota check <path> --repair`; this rewrites UsedInodes/UsedSpace from the fresh summary via doSetQuota.","Inspect the logged warning just before the error (quota(...) != summary(...)) to gauge the drift magnitude before repairing.","If drift recurs, check for mixed client versions / known quota bugs and upgrade all clients.","Verify no other writes are mutating the tree during check/repair to avoid a new race."],"exampleFix":"// before\n$ juicefs quota check /mnt/jfs/data\n// ERROR: quota of /mnt/jfs/data is inconsistent, please repair it with --repair flag\n// after\n$ juicefs quota check /mnt/jfs/data --repair","handlingStrategy":"try-catch","validationCode":"// pre-compute expected usage to detect drift before official check\nvar sum meta.Summary\nif st := m.GetSummary(ctx, ino, &sum, true, false); st == 0 {\n    if q.UsedInodes != int64(sum.Dirs+sum.Files)-1 || q.UsedSpace != int64(sum.Size)-int64(4096) {\n        logger.Warn(\"quota drift detected; run check with --repair\")\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := quotaCheck(path, false); err != nil && strings.Contains(err.Error(), \"--repair flag\") {\n    err = quotaCheck(path, true) // retry in repair mode\n}","preventionTips":["Schedule periodic `juicefs quota check --repair` to self-heal drift.","Upgrade all clients to the same version to avoid accounting bugs.","Avoid restoring metadata from old backups without a subsequent quota repair."],"tags":["metadata","quota","consistency"],"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"}