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

  1. Check the wrapped driver error for the precise cause (denied, full, exists-incompatibly).
  2. Grant CREATE/ALTER privileges or restore schema ownership to the JuiceFS DB role.
  3. Raise or remove schema-level table/space quotas on the database.
  4. After backup, drop an incompatible dirStats table and retry init.
  5. 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

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


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/a61932b8d834cf9b. Report an issue: GitHub.