{"record":{"id":"bbe61b5fbe993de7","repo":"juicedata/juicefs","slug":"delete-user-group-quota","errorCode":null,"errorMessage":"delete user group quota","messagePattern":"delete user group quota","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/tkv.go","lineNumber":553,"sourceCode":"\t\t\t\tm.genLog(tx, time.Now(), \"INIT_ENABLE_DIRSTATS()\")\n\t\t\t\treturn nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrap(err, \"delete dir stats\")\n\t\t\t}\n\t\t}\n\t\tif !old.UserGroupQuota && format.UserGroupQuota {\n\t\t\t// remove user group quota as they are outdated\n\t\t\tuserPrefix := m.fmtKey(\"QU\")\n\t\t\tgroupPrefix := m.fmtKey(\"QG\")\n\t\t\terr := m.txn(Background(), func(tx *kvTxn) error {\n\t\t\t\ttx.deleteKeys(userPrefix)\n\t\t\t\ttx.deleteKeys(groupPrefix)\n\t\t\t\tm.genLog(tx, time.Now(), \"INIT_ENABLE_USERGROUPQUOTA()\")\n\t\t\t\treturn nil\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrap(err, \"delete user group quota\")\n\t\t\t}\n\t\t}\n\t\tif err = format.update(&old, force); err != nil {\n\t\t\treturn errors.Wrap(err, \"update format\")\n\t\t}\n\t}\n\n\tdata, err := json.MarshalIndent(format, \"\", \"\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"json: %s\", err)\n\t}\n\n\tm.setFormat(format)\n\tts := time.Now().Unix()\n\tattr := &Attr{\n\t\tTyp:    TypeDirectory,\n\t\tAtime:  ts,\n\t\tMtime:  ts,","sourceCodeStart":535,"sourceCodeEnd":571,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/tkv.go#L535-L571","documentation":"In kvMeta.doInit (pkg/meta/tkv.go:553), when the format update enables UserGroupQuota, outdated user/group quota keys (prefixes \"QU\"/\"QG\") are deleted in a write transaction; failure is wrapped as \"delete user group quota\". This cleanup exists because quota records from before the feature flag are considered stale.","triggerScenarios":"Running `juicefs format` (or a mount that updates the format) with --enable-user-group-quota on a KV-engine volume where old.UserGroupQuota was false, and the delete transaction fails (store unavailable, transaction too large, write conflict).","commonSituations":"First-time enablement of user/group quotas on large TiKV/etcd volumes with many leftover quota keys; KV backend in read-only or degraded state; concurrent format operations.","solutions":["Retry the format command once the KV cluster is healthy; the cleanup only runs on the false→true transition.","If TiKV reports transaction too large, delete stale QU/QG keys in batches or upgrade to a JuiceFS version handling the cleanup incrementally.","Check backend writability (etcd disk limits, Badger dir permissions, FDB cluster status) based on the wrapped error."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"null","typeGuard":null,"tryCatchPattern":"if err := formatVolume(); err != nil {\n    if strings.Contains(err.Error(), \"delete user group quota\") {\n        // inspect wrapped store error; verify writability and retry\n    }\n}","preventionTips":["Confirm the KV backend is writable (etcd quota, Badger dir permissions, FDB cluster status) before enabling quotas.","Run the format transition during quiet periods to avoid write conflicts.","Watch for TiKV 'transaction too large' errors and pre-clean QU/QG keys on large volumes."],"tags":["go","kv","format","quota","transaction"],"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"}