{"record":{"id":"a61932b8d834cf9b","repo":"juicedata/juicefs","slug":"create-table-dirstats-s","errorCode":null,"errorMessage":"create table dirStats: %s","messagePattern":"create table dirStats: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/sql.go","lineNumber":598,"sourceCode":"\t\treturn fmt.Errorf(\"create table setting, counter: %s\", err)\n\t}\n\tif err := m.syncTable(new(edge)); err != nil {\n\t\treturn fmt.Errorf(\"create table edge: %s\", err)\n\t}\n\tif err := m.syncTable(new(node), new(symlink), new(xattr)); err != nil {\n\t\treturn fmt.Errorf(\"create table node, symlink, xattr: %s\", err)\n\t}\n\tif err := m.syncTable(new(chunk), new(sliceRef), new(delslices)); err != nil {\n\t\treturn fmt.Errorf(\"create table chunk, chunk_ref, delslices: %s\", err)\n\t}\n\tif err := m.syncTable(new(session2), new(sustained), new(delfile)); err != nil {\n\t\treturn fmt.Errorf(\"create table session2, sustaind, delfile: %s\", err)\n\t}\n\tif err := m.syncTable(new(flock), new(plock), new(dirQuota), new(userGroupQuota)); err != nil {\n\t\treturn fmt.Errorf(\"create table flock, plock, dirQuota, userGroupQuota: %s\", err)\n\t}\n\tif err := m.syncTable(new(dirStats)); err != nil {\n\t\treturn fmt.Errorf(\"create table dirStats: %s\", err)\n\t}\n\tif err := m.syncTable(new(detachedNode)); err != nil {\n\t\treturn fmt.Errorf(\"create table detachedNode: %s\", err)\n\t}\n\tif err := m.syncTable(new(acl)); err != nil {\n\t\treturn fmt.Errorf(\"create table acl: %s\", err)\n\t}\n\tif err := m.syncTable(new(delegationToken)); err != nil {\n\t\treturn fmt.Errorf(\"create table delegationToken: %s\", err)\n\t}\n\tif err := m.syncTable(new(changeLog)); err != nil {\n\t\treturn fmt.Errorf(\"create table changeLog: %s\", err)\n\t}\n\treturn nil\n}\n\nfunc (m *dbMeta) doInit(format *Format, force bool) error {\n\tif err := m.syncAllTables(); err != nil {","sourceCodeStart":580,"sourceCodeEnd":616,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/sql.go#L580-L616","documentation":"syncAllTables (pkg/meta/sql.go:597) creates/auto-migrates the `dirStats` table via xorm Sync2; failure is wrapped as \"create table dirStats: %s\". dirStats caches per-directory statistics used by `juicefs summary`/dir usage accounting. Failure aborts metadata engine initialization.","triggerScenarios":"Metadata engine initialization when Sync2 on dirStats fails: insufficient privileges at this point in the sequence, storage limits reached after earlier tables consumed space, or an incompatible existing dirStats table.","commonSituations":"Quota on the DB schema (max tables/space) exceeded by earlier init steps; DB user's rights revoked between volume format and remount; schema owner changed by a DBA.","solutions":["Check the wrapped driver error for the precise cause (denied, full, exists-incompatibly).","Grant CREATE/ALTER privileges or restore schema ownership to the JuiceFS DB role.","Raise or remove schema-level table/space quotas on the database.","After backup, drop an incompatible dirStats table and retry init.","Confirm connectivity was stable; transient failures can be fixed by simply re-running."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Preflight: schema table/space quota headroom\n// MySQL:\n//   SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='jfs';\n//   SELECT data_length+index_length FROM information_schema.tables WHERE table_schema='jfs';\n// Compare against any DBA-imposed limits before initializing.","typeGuard":null,"tryCatchPattern":"if err := initMeta(); err != nil {\n    if strings.Contains(err.Error(), \"create table dirStats\") {\n        return fmt.Errorf(\"dirStats DDL failed; check schema quotas and grants: %w\", err)\n    }\n    return err\n}","preventionTips":["Ask the DBA to remove artificial table-count or space quotas on the JuiceFS schema.","Keep schema ownership stable; re-grant CREATE after any ownership change.","Re-run init after fixing transient failures — Sync2 skips already-created tables.","Confirm charset/collation of any pre-existing dirStats table matches the database default."],"tags":["database","schema-migration","ddl","stats"],"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"}