juicedata/juicefs · error

create table edge: %s

Error message

create table edge: %s

What it means

syncAllTables (pkg/meta/sql.go:582) calls syncTable(new(edge)) to create/auto-migrate the `edge` table via xorm Sync2; on failure the error is wrapped as "create table edge: %s". The edge table stores directory entries, so this failure aborts metadata engine initialization. Duplicate-key errors from concurrent creation are already tolerated by syncTable; any other DDL error surfaces here.

Source

Thrown at pkg/meta/sql.go:583

		}
		return err
	})
}

func (m *dbMeta) syncTable(beans ...interface{}) error {
	err := m.db.Sync2(beans...)
	if err != nil && strings.Contains(err.Error(), "Duplicate key") {
		err = nil
	}
	return err
}

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)

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Read the wrapped inner error to identify whether it is a privilege, storage, or schema conflict.
  2. Grant CREATE/ALTER privileges on the schema to the JuiceFS database user.
  3. If a previous failed init left a corrupt edge table, back up then drop it so Sync2 can recreate it.
  4. Check DB server disk space and that the database is not in read-only mode.
  5. Verify the database server version is supported by JuiceFS.
Defensive patterns

Strategy: validation

Validate before calling

// Preflight: confirm DDL rights and that no incompatible 'edge' table exists
// SQL (adjust prefix):
//   SHOW CREATE TABLE jfs_edge;      -- MySQL: check schema matches expectations
//   SELECT has_schema_privilege(current_user, 'public', 'CREATE'); -- PostgreSQL
// If the privilege call returns false or the table schema is foreign, fix before mounting.

Try / catch

if err := mount(); err != nil {
    if strings.Contains(err.Error(), "create table edge") {
        return fmt.Errorf("edge table DDL failed; check grants/leftover schema: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Initializing a SQL metadata engine when Sync2 on the edge table fails: privilege or storage problems, an existing edge table with a conflicting/incompatible schema, or a driver-specific DDL limitation.

Common situations: Partial initialization from a previously failed run left a broken edge table; managed DB restricts ALTER; MySQL version too old for the generated column/index syntax used by the table definition.

Related errors


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