juicedata/juicefs · error

update table session2, delslices, dirstats, detachedNode, di

Error message

update table session2, delslices, dirstats, detachedNode, dirQuota, userGroupQuota, acl, changeLog: %s

What it means

doNewSession performs a schema upgrade for legacy volumes by syncing all tables added after the original schema (session2, delslices, dirStats, detachedNode, dirQuota, userGroupQuota, acl, delegationToken, changeLog). Failure is wrapped with this message and prevents the session (mount) from starting.

Source

Thrown at pkg/meta/sql.go:768

			return err
		} else if !ok {
			return nil
		}
		s := setting{Name: "format"}
		ok, err := ses.Get(&s)
		if err == nil && ok {
			data = []byte(s.Value)
		}
		return err
	})
	return
}

func (m *dbMeta) doNewSession(sinfo []byte, update bool) error {
	// add new table
	err := m.syncTable(new(session2), new(delslices), new(dirStats), new(detachedNode), new(dirQuota), new(userGroupQuota), new(acl), new(delegationToken), new(changeLog))
	if err != nil {
		return fmt.Errorf("update table session2, delslices, dirstats, detachedNode, dirQuota, userGroupQuota, acl, changeLog: %s", err)
	}
	// add node table
	if err = m.syncTable(new(node)); err != nil {
		return fmt.Errorf("update table node: %s", err)
	}
	// add primary key
	if err = m.syncTable(new(edge), new(chunk), new(xattr), new(sustained)); err != nil {
		return fmt.Errorf("update table edge, chunk, xattr, sustained: %s", err)
	}
	// update the owner from uint64 to int64
	if err = m.syncTable(new(flock), new(plock)); err != nil {
		return fmt.Errorf("update table flock, plock: %s", err)
	}

	for {
		beans := session2{Sid: m.sid, Expire: m.expireTime(), Info: sinfo}
		if update {
			return m.txn(func(s *xorm.Session) error {

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Grant CREATE/ALTER privileges so the one-time schema upgrade can complete
  2. Run the mount once with an account that has DDL rights; afterwards regular DML rights suffice
  3. Back up metadata (juicefs dump) before the upgrade and check the wrapped error for the failing table
  4. Ensure no other mount is concurrently migrating the same schema

Example fix

-- before
GRANT SELECT, INSERT, UPDATE, DELETE ON jfs.* TO 'jfs'@'%';
-- after
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER ON jfs.* TO 'jfs'@'%';
Defensive patterns

Strategy: validation

Validate before calling

// Verify DDL rights before mounting a legacy volume
SELECT COUNT(*) FROM information_schema.schema_privileges
WHERE grantee LIKE "'jfs'%" AND privilege_type IN ('CREATE','ALTER');

Try / catch

if err := m.Open(sqlURL); err != nil {
    log.Fatalf("legacy schema upgrade failed, grant DDL rights and retry: %v", err)
}

Prevention

When it happens

Trigger: Mounting a volume whose metadata was created by a very old JuiceFS version, when xorm Sync2 fails to create/alter any of the legacy-upgrade tables — missing DDL privileges, DB connection drop, or unsupported migration.

Common situations: Upgrading a long-lived MySQL/PostgreSQL volume to a modern JuiceFS client; DB account used for mount lacks ALTER rights needed by the one-time upgrade.

Related errors


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