{"record":{"id":"78f1eb6948d8c6f2","repo":"juicedata/juicefs","slug":"drop-table-usergroupquota","errorCode":null,"errorMessage":"drop table userGroupQuota","messagePattern":"drop table userGroupQuota","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/sql.go","lineNumber":660,"sourceCode":"\t\t\t\tm.genLog(Background(), s, time.Now().UnixNano(), \"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, \"drop table dirStats\")\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\terr = m.txn(func(s *xorm.Session) error {\n\t\t\t\t_, err := s.Where(\"TRUE\").Delete(new(userGroupQuota))\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tm.genLog(Background(), s, time.Now().UnixNano(), \"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, \"drop table userGroupQuota\")\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\tn := &node{\n\t\tType:   TypeDirectory,\n\t\tNlink:  2,\n\t\tLength: 4 << 10,\n\t\tParent: RootInode,","sourceCodeStart":642,"sourceCodeEnd":678,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/sql.go#L642-L678","documentation":"During `juicefs format` on an existing SQL metadata volume, when the new format enables UserGroupQuota while the stored format had it disabled, all rows in the userGroupQuota table are deleted in a transaction because they are considered outdated. Failure of that transactional DELETE is wrapped as \"drop table userGroupQuota\" and aborts formatting.","triggerScenarios":"`juicefs format` (or re-format with --force paths in doInit) against a MySQL/Postgres/SQLite metadata URL where old format has UserGroupQuota=false and new format sets it to true, and the DELETE on userGroupQuota fails (DB error, lock wait, permissions).","commonSituations":"Enabling user/group quotas on an existing volume; DB account missing DELETE privilege; lock contention from other clients writing quotas; transient connection failure.","solutions":["Retry `juicefs format` after confirming DB connectivity","Grant the DB user DELETE privilege on the userGroupQuota table","Inspect the wrapped cause for lock/deadlock errors and reduce concurrent quota updates or increase lock wait timeout","Backup metadata with `juicefs dump` before reformatting"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// ensure the DB account can delete from userGroupQuota\nrows, err := db.Query(\"SELECT 1 FROM userGroupQuota LIMIT 1\")","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"drop table userGroupQuota\") {\n    // read wrapped cause, fix privileges/locks, retry format\n}","preventionTips":["Grant DELETE on userGroupQuota before enabling user/group quotas","Avoid reformatting while clients are actively setting quotas","Dump metadata before enabling new format flags"],"tags":["database","sql","metadata","quota"],"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"}