juicedata/juicefs · error

create table blob: %s

Error message

create table blob: %s

What it means

After opening the engine, newSQLStore runs engine.Sync2(new(blob)) to create/migrate the jfs_blob table; failure here is wrapped as 'create table blob'. This means the connection succeeded but DDL failed — typically a permissions or server-side error surfaced by xorm.

Source

Thrown at pkg/object/sql.go:205

	}
	switch logger.Level { // make xorm less verbose
	case logrus.TraceLevel:
		engine.SetLogLevel(log.LOG_DEBUG)
	case logrus.DebugLevel:
		engine.SetLogLevel(log.LOG_INFO)
	case logrus.InfoLevel, logrus.WarnLevel:
		engine.SetLogLevel(log.LOG_WARNING)
	case logrus.ErrorLevel:
		engine.SetLogLevel(log.LOG_ERR)
	default:
		engine.SetLogLevel(log.LOG_OFF)
	}
	if searchPath != "" {
		engine.SetSchema(searchPath)
	}
	engine.SetTableMapper(names.NewPrefixMapper(engine.GetTableMapper(), "jfs_"))
	if err := engine.Sync2(new(blob)); err != nil {
		return nil, fmt.Errorf("create table blob: %s", err)
	}
	return &sqlStore{DefaultObjectStorage{}, engine, addr}, nil
}

func removeScheme(addr string) string {
	p := strings.Index(addr, "://")
	if p > 0 {
		addr = addr[p+3:]
	}
	return addr
}

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Grant the DB user CREATE privilege: GRANT CREATE ON DATABASE jfs TO juicefs; (postgres) or CREATE, ALTER privileges (mysql).
  2. For postgres with search_path, create the schema first: CREATE SCHEMA jfs; AUTHORIZATION juicefs; and GRANT USAGE.
  3. Verify the database accepts DDL (not read-only) and check server logs for the underlying xorm error detail wrapped in the message.

Example fix

// before (fails: schema missing)
meta := "postgres://user:pw@host/db?search_path=jfs"
// after (pre-create schema + grants)
-- psql: CREATE SCHEMA jfs AUTHORIZATION "user";
meta := "postgres://user:pw@host/db?search_path=jfs"
Defensive patterns

Strategy: retry

Validate before calling

// postgres preflight
rows, err := db.Query("SELECT has_schema_privilege(current_user, $1, 'CREATE')", schema)
// or simply try: CREATE TABLE IF NOT EXISTS jfs_blob (...) in a preflight check

Try / catch

if err := engine.Sync2(new(blob)); err != nil {
    if pgErr, ok := err.(pgconn.PgError); ok && pgErr.Code == "42501" {
        return fmt.Errorf("grant CREATE privilege to the DB user, then retry: %w", err)
    }
    return fmt.Errorf("create table blob: %w", err)
}

Prevention

When it happens

Trigger: engine.Sync2 returns an error: DB user lacks CREATE privilege on the schema/database, the search_path schema doesn't exist (postgres), table exists with incompatible structure, storage full, or the connection dropped mid-DDL.

Common situations: Restricted database user with only DML privileges; postgres search_path pointing to a schema that was never created; managed DB (RDS) policies blocking DDL; network interruption between connect and schema sync.

Related errors


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