juicedata/juicefs · error
create table session2, sustaind, delfile: %s
Error message
create table session2, sustaind, delfile: %s
What it means
syncAllTables (pkg/meta/sql.go:591) creates/auto-migrates the `session2`, `sustained`, and `delfile` tables via xorm Sync2; failure is wrapped as "create table session2, sustaind, delfile: %s". These tables track active client sessions, sustained (open) files, and pending deletions. DDL failure aborts initialization; note the message says 'sustaind' (historical spelling) for the `sustained` table.
Source
Thrown at pkg/meta/sql.go:592
}
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)
}
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)View on GitHub (pinned to c9a67b23e8)
Solutions
- Read the wrapped driver error to identify privilege, storage, or schema conflict and address that root cause.
- Ensure the user has CREATE/ALTER privileges on the schema.
- If upgrading from an old version, back up and check the session2 table schema; allow Sync2 to migrate or manually drop corrupt leftovers.
- Retry the init after transient connection errors; Sync2 is idempotent.
- Check the DB server log for the detailed DDL failure reason.
Defensive patterns
Strategy: validation
Validate before calling
// Preflight: ensure session tables are either absent or migrateable // MySQL: // SHOW TABLES LIKE 'jfs_session2'; // SHOW GRANTS FOR CURRENT_USER(); -- CREATE + ALTER required // If present and old, take a metadata backup (juicefs dump) before upgrading.
Try / catch
if err := initMeta(); err != nil {
if strings.Contains(err.Error(), "create table session2, sustaind, delfile") {
return fmt.Errorf("session table migration failed; check grants/schema: %w", err)
}
return err
} Prevention
- Read the release notes when upgrading JuiceFS: session2 schema changes require ALTER rights.
- Keep a dedicated DB role with persistent CREATE/ALTER grants for the metadata schema.
- Retry init on transient errors — the sequence is idempotent.
- Watch the DB error log during init for the underlying DDL failure detail.
When it happens
Trigger: Metadata engine initialization when Sync2 on session2/sustained/delfile fails: privileges, storage, connection loss, or an existing table with conflicting column types from an older schema.
Common situations: Old volumes where session2 schema changed between JuiceFS versions and ALTER fails; DB user restricted to DML only; transient network drop during long-running init.
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 flock, plock, dirQuota, userGroupQuota: %s
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/ab9502a704758c04.
Report an issue: GitHub.