{"record":{"id":"f35b44da0d81da8f","repo":"juicedata/juicefs","slug":"set-s-quota-w","errorCode":null,"errorMessage":"set %s quota: %w","messagePattern":"set (.+?) quota: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/quota.go","lineNumber":1045,"sourceCode":"\t\t\tquota.MaxInodes = q.MaxInodes\n\t\t}\n\t\tif _, err := m.en.doSetQuota(ctx, qtype, id, quota); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (m *baseMeta) repairUgUsage(ctx Context, qtype uint32, usageMap map[uint64]*Summary, quotaMap map[uint64]*Quota) error {\n\tidType := \"uid\"\n\tif qtype == GroupQuotaType {\n\t\tidType = \"gid\"\n\t}\n\tif err := m.en.cleanUgUsage(ctx, qtype); err != nil {\n\t\treturn fmt.Errorf(\"clean %s quotas: %w\", idType, err)\n\t}\n\tif err := m.repairUsage(ctx, usageMap, quotaMap, qtype); err != nil {\n\t\treturn fmt.Errorf(\"set %s quota: %w\", idType, err)\n\t}\n\treturn nil\n}\n\nfunc (m *baseMeta) checkUGUsage(ctx Context, repair bool, quotas map[string]*Quota) error {\n\tuserUsage, groupUsage, err := m.scanGlobalUserGroupUsage(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"scan global user group usage: %w\", err)\n\t}\n\n\t_, userQuotas, groupQuotas, err := m.en.doLoadQuotas(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"load user/group quotas: %w\", err)\n\t}\n\thasErr := m.compareUGUsage(userUsage, userQuotas, UserQuotaType, quotas)\n\thasErr = m.compareUGUsage(groupUsage, groupQuotas, GroupQuotaType, quotas) || hasErr\n\n\tif !repair {","sourceCodeStart":1027,"sourceCodeEnd":1063,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/quota.go#L1027-L1063","documentation":"Raised by baseMeta.repairUgUsage (pkg/meta/quota.go:1045) when repairUsage fails after cleanUgUsage succeeded. At this point old uid/gid usage records were already wiped, so this error leaves user/group quota usage in a partially repaired state and must be retried to restore correct UsedInodes/UsedSpace values.","triggerScenarios":"`juicefs quota check --repair` on user/group quotas where doSetQuota/repairUsage errors while writing repaired usage back (backend write failure, quota set rejected, engine outage mid-repair).","commonSituations":"Metadata engine failure between the clean and set phases; individual quota set rejected by backend; disk full on SQL engine; connection drop mid-repair.","solutions":["Re-run `juicefs quota check --repair` immediately — cleaning is idempotent and the set phase will be retried to a consistent state.","Read the wrapped %w error to identify the specific backend write failure and address it (connectivity, disk, permissions).","After a successful retry, verify with `juicefs quota list` that uid/gid usage values match actual usage.","If repeated failures occur, repair one uid/gid at a time to isolate the failing record."],"exampleFix":"// before: repair aborted mid-way (clean done, set failed)\n// after: rerun to completion\n$ juicefs quota check --repair /mnt/jfs\n$ juicefs quota list  # verify uid/gid usage consistent","handlingStrategy":"retry","validationCode":"// confirm engine writable before starting clean+set\nif err := m.en.doSetQuota(ctx, qtype, probeKey, probeQuota); err != nil {\n    return fmt.Errorf(\"engine not writable; skip repair: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := repairUgUsage(ctx, qtype, usageMap, quotaMap); err != nil && strings.Contains(err.Error(), \"set \") {\n    // clean already happened; rerun so the set phase completes\n    return repairUgUsage(ctx, qtype, usageMap, quotaMap)\n}","preventionTips":["Always re-run the full `quota check --repair` if it fails mid-way — the two phases are not atomic.","Verify with `juicefs quota list` after every repair.","Keep the metadata engine on stable storage with sufficient disk space.","Repair one uid/gid at a time when records are numerous."],"tags":["metadata","quota","repair","backend"],"backgroundTag":"database-write-failed","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}