juicedata/juicefs · error
create table setting, counter: %s
Error message
create table setting, counter: %s
What it means
In syncAllTables (pkg/meta/sql.go), JuiceFS uses xorm Sync2 to create/auto-migrate the `setting` and `counter` tables. If that DDL fails, the error is wrapped as "create table setting, counter: %s". This is the first schema step of `doInit`, so it typically indicates the database user cannot create tables or the underlying DDL hit a driver/compatibility problem.
Source
Thrown at pkg/meta/sql.go:580
_, err := s.Delete(&sliceRef{Id: id})
if err == nil {
m.genLog(Background(), s, time.Now().UnixNano(), "DELETESLICE(%d,%d)", id, size)
}
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)View on GitHub (pinned to c9a67b23e8)
Solutions
- Grant the database user CREATE and ALTER privileges on the target schema/database.
- Check the wrapped inner error: read-only filesystem or 'access denied' indicates privilege/storage issues to fix on the DB side.
- Verify no pre-existing table with the same (prefixed) name has an incompatible schema that Sync2 cannot migrate; drop or rename it after backing up.
- Confirm the database server has free disk space and is writable.
- Test manually with the same credentials: run a `CREATE TABLE` in a SQL client to confirm DDL is permitted.
Example fix
// before: user lacks DDL rights CREATE USER 'jfs'@'%' IDENTIFIED BY '...'; GRANT SELECT, INSERT ON juicefs.* TO 'jfs'@'%'; // after: grant full DDL rights GRANT ALL PRIVILEGES ON juicefs.* TO 'jfs'@'%';
Defensive patterns
Strategy: validation
Validate before calling
// Before initializing, verify the DB user can perform DDL // run with the same credentials as the meta URL: // MySQL: // CREATE TABLE jfs__ddl_probe (id BIGINT PRIMARY KEY); DROP TABLE jfs__ddl_probe; // PostgreSQL: // CREATE TABLE __ddl_probe (id BIGINT PRIMARY KEY); DROP TABLE __ddl_probe; // If either statement fails with 'access denied', fix grants before running juicefs format/mount.
Try / catch
// Catch the wrapped schema error and fail fast with an actionable hint
if err := cmd.Run(); err != nil {
if strings.Contains(err.Error(), "create table setting, counter") {
return fmt.Errorf("metadata init failed: ensure DB user has CREATE/ALTER privileges: %w", err)
}
return err
} Prevention
- Grant ALL (or at least CREATE + ALTER + INDEX) on the metadata schema to the JuiceFS DB role at provisioning time.
- Keep the DB user dedicated to JuiceFS so rights are not accidentally revoked.
- Test DDL capability after any DB permission or managed-policy change.
- Use a consistent tablePrefix and avoid reusing schemas that contain foreign tables.
When it happens
Trigger: Any command that initializes the SQL metadata engine (`juicefs format`, `juicefs mount`, `juicefs status`) when Sync2 on (setting, counter) fails: insufficient CREATE privileges, read-only database, disk-full on the DB host, or incompatible SQL dialect.
Common situations: DB user granted only SELECT/INSERT but not CREATE/ALTER; connecting to a managed DB where DDL is restricted; table prefix collides with an existing incompatible table of the same name; server out of disk space.
Related errors
- create table edge: %s
- create table node, symlink, xattr: %s
- create table chunk, chunk_ref, delslices: %s
- create table session2, sustaind, delfile: %s
- create table flock, plock, dirQuota, userGroupQuota: %s
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/d9c1e84733f1f407.
Report an issue: GitHub.