juicedata/juicefs · error
create table dirStats: %s
Error message
create table dirStats: %s
What it means
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.
Source
Thrown at pkg/meta/sql.go:598
return fmt.Errorf("create table setting, counter: %s", err)
}
if err := m.syncTable(new(edge)); err != nil {
return fmt.Errorf("create table edge: %s", err)
}
if err := m.syncTable(new(node), new(symlink), new(xattr)); err != nil {
return fmt.Errorf("create table node, symlink, xattr: %s", err)
}
if err := m.syncTable(new(chunk), new(sliceRef), new(delslices)); err != nil {
return fmt.Errorf("create table chunk, chunk_ref, delslices: %s", err)
}
if err := m.syncTable(new(session2), new(sustained), new(delfile)); err != nil {
return fmt.Errorf("create table session2, sustaind, delfile: %s", err)
}
if err := m.syncTable(new(flock), new(plock), new(dirQuota), new(userGroupQuota)); err != nil {
return fmt.Errorf("create table flock, plock, dirQuota, userGroupQuota: %s", err)
}
if err := m.syncTable(new(dirStats)); err != nil {
return fmt.Errorf("create table dirStats: %s", err)
}
if err := m.syncTable(new(detachedNode)); err != nil {
return fmt.Errorf("create table detachedNode: %s", err)
}
if err := m.syncTable(new(acl)); err != nil {
return fmt.Errorf("create table acl: %s", err)
}
if err := m.syncTable(new(delegationToken)); err != nil {
return fmt.Errorf("create table delegationToken: %s", err)
}
if err := m.syncTable(new(changeLog)); err != nil {
return fmt.Errorf("create table changeLog: %s", err)
}
return nil
}
func (m *dbMeta) doInit(format *Format, force bool) error {
if err := m.syncAllTables(); err != nil {View on GitHub (pinned to c9a67b23e8)
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.
Defensive patterns
Strategy: validation
Validate before calling
// Preflight: schema table/space quota headroom // MySQL: // SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='jfs'; // SELECT data_length+index_length FROM information_schema.tables WHERE table_schema='jfs'; // Compare against any DBA-imposed limits before initializing.
Try / catch
if err := initMeta(); err != nil {
if strings.Contains(err.Error(), "create table dirStats") {
return fmt.Errorf("dirStats DDL failed; check schema quotas and grants: %w", err)
}
return err
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- create table setting, counter: %s
- create table edge: %s
- create table node, symlink, xattr: %s
- create table chunk, chunk_ref, delslices: %s
- create table session2, sustaind, delfile: %s
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/a61932b8d834cf9b.
Report an issue: GitHub.