juicedata/juicefs · error

create table flock, plock, dirQuota, userGroupQuota: %s

Error message

create table flock, plock, dirQuota, userGroupQuota: %s

What it means

syncAllTables (pkg/meta/sql.go:594) creates/auto-migrates the lock and quota tables `flock`, `plock`, `dirQuota`, and `userGroupQuota` via xorm Sync2; failure is wrapped as "create table flock, plock, dirQuota, userGroupQuota: %s". These tables back POSIX locks and directory/user-group quotas. Failure aborts metadata initialization.

Source

Thrown at pkg/meta/sql.go:595

func (m *dbMeta) syncAllTables() error {
	if err := m.syncTable(new(setting), new(counter)); err != nil {
		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
}

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Inspect the wrapped inner error (permission denied / disk full / type conflict) and fix the DB-side cause.
  2. Ensure the connecting role owns the schema or has CREATE/ALTER rights on it.
  3. For PostgreSQL, verify search_path points to a schema the user can create tables in.
  4. Free DB storage if exhausted, then re-run initialization.
  5. Back up and drop any incompatible leftover tables of the same names.
Defensive patterns

Strategy: validation

Validate before calling

// Preflight PostgreSQL schema ownership before init
//   SELECT has_schema_privilege(current_user, 'public', 'CREATE');
//   SELECT tableowner FROM pg_tables WHERE tablename LIKE '%flock';
// MySQL: SHOW GRANTS FOR CURRENT_USER(); -- needs CREATE, ALTER, INDEX

Try / catch

if err := initMeta(); err != nil {
    if strings.Contains(err.Error(), "create table flock, plock, dirQuota, userGroupQuota") {
        return fmt.Errorf("lock/quota table DDL failed; verify schema ownership and grants: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Metadata engine initialization when Sync2 on the lock/quota beans fails: DDL privileges missing, storage exhaustion, or a quota table with an incompatible pre-existing schema.

Common situations: Tightened DB grants after initial provisioning; managed PostgreSQL with restricted schema ownership (tables owned by another role); disk full on the DB host.

Related errors


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