{"record":{"id":"54ac2f1ed852e4dc","repo":"juicedata/juicefs","slug":"load-user-group-quotas-w","errorCode":null,"errorMessage":"load user/group quotas: %w","messagePattern":"load user/group quotas: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/quota.go","lineNumber":1058,"sourceCode":"\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 {\n\t\tif hasErr {\n\t\t\treturn fmt.Errorf(\"user/group quota is inconsistent, please repair it with --repair flag\")\n\t\t}\n\t\treturn nil\n\t}\n\n\tlogger.Infof(\"Begin to repair user/group quota.\")\n\tif err = m.repairUgUsage(ctx, UserQuotaType, userUsage, userQuotas); err != nil {\n\t\treturn err\n\t}\n\tif err = m.repairUgUsage(ctx, GroupQuotaType, groupUsage, groupQuotas); err != nil {\n\t\treturn err\n\t}","sourceCodeStart":1040,"sourceCodeEnd":1076,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/quota.go#L1040-L1076","documentation":"This error wraps a failure from `doLoadQuotas`, the engine-level call that loads all persisted user (uid) and group (gid) quota records from the metadata engine. `checkUGUsage` (pkg/meta/quota.go:1056-1058) needs both the scanned global user/group usage and the stored quota records to compare them during `juicefs quota check`; if the underlying engine (Redis/SQL/KV) fails to enumerate quotas, the error is wrapped with this message. It means the quota consistency check could not even read the quota table — it is not a report of inconsistency itself.","triggerScenarios":"Running `juicefs quota check` (handleQuotaCheck -> checkUGUsage) against a metadata engine whose quota records cannot be read: engine connection failure mid-command, SQL schema/table corruption, Redis scan errors, or the engine returning an error from its doLoadQuotas implementation.","commonSituations":"Metadata engine restarted or network dropped while the check runs; SQL volume where the quota table is missing/damaged (e.g. partial restore from backup); Redis cluster failover during the scan; insufficient permissions on the metadata store.","solutions":["Check connectivity to the metadata engine (redis/sql/kv URL) and retry the quota check command.","Inspect the wrapped cause (%w) in the error output to identify the engine-specific failure (auth, timeout, missing table).","For SQL engines, verify the quota tables exist and match the current JuiceFS schema (re-run migrations or restore a consistent backup).","Verify credentials/ACLs on the metadata engine allow reading all keys/rows."],"exampleFix":"// before\n_, userQuotas, groupQuotas, err := m.en.doLoadQuotas(ctx)\nif err != nil {\n\treturn fmt.Errorf(\"load user/group quotas: %w\", err)\n}\n// after\n_, userQuotas, groupQuotas, err := m.en.doLoadQuotas(ctx)\nif err != nil {\n\treturn fmt.Errorf(\"load user/group quotas: %w\", err) // inspect wrapped err; e.g. retry with backoff if it is a transient engine error\n}","handlingStrategy":"retry","validationCode":"// before running quota check, verify engine reachability\nc, err := net.DialTimeout(\"tcp\", \"redis-host:6379\", 3*time.Second)\nif err != nil { return fmt.Errorf(\"metadata engine unreachable: %w\", err) }\nc.Close()","typeGuard":null,"tryCatchPattern":"err := meta.CheckQuota(ctx, repair)\nif err != nil && strings.Contains(err.Error(), \"load user/group quotas\") {\n\t// transient engine failure: retry with backoff\n\treturn retryWithBackoff(3, 2*time.Second, func() error { return meta.CheckQuota(ctx, repair) })\n}","preventionTips":["Run quota checks against a stable, primary metadata endpoint (avoid failover windows).","Monitor metadata engine health before scheduling maintenance jobs.","Always log the fully unwrapped error chain (%+v) to capture the engine-level cause."],"tags":["metadata","quota","redis","sql","kv"],"backgroundTag":"database-query-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"}