{"record":{"id":"69fdc27bb4feb624","repo":"juicedata/juicefs","slug":"update-table-session2-delslices-dirstats-detach","errorCode":null,"errorMessage":"update table session2, delslices, dirstats, detachedNode, dirQuota, userGroupQuota, acl, changeLog: %s","messagePattern":"update table session2, delslices, dirstats, detachedNode, dirQuota, userGroupQuota, acl, changeLog: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/sql.go","lineNumber":768,"sourceCode":"\t\t\treturn err\n\t\t} else if !ok {\n\t\t\treturn nil\n\t\t}\n\t\ts := setting{Name: \"format\"}\n\t\tok, err := ses.Get(&s)\n\t\tif err == nil && ok {\n\t\t\tdata = []byte(s.Value)\n\t\t}\n\t\treturn err\n\t})\n\treturn\n}\n\nfunc (m *dbMeta) doNewSession(sinfo []byte, update bool) error {\n\t// add new table\n\terr := m.syncTable(new(session2), new(delslices), new(dirStats), new(detachedNode), new(dirQuota), new(userGroupQuota), new(acl), new(delegationToken), new(changeLog))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"update table session2, delslices, dirstats, detachedNode, dirQuota, userGroupQuota, acl, changeLog: %s\", err)\n\t}\n\t// add node table\n\tif err = m.syncTable(new(node)); err != nil {\n\t\treturn fmt.Errorf(\"update table node: %s\", err)\n\t}\n\t// add primary key\n\tif err = m.syncTable(new(edge), new(chunk), new(xattr), new(sustained)); err != nil {\n\t\treturn fmt.Errorf(\"update table edge, chunk, xattr, sustained: %s\", err)\n\t}\n\t// update the owner from uint64 to int64\n\tif err = m.syncTable(new(flock), new(plock)); err != nil {\n\t\treturn fmt.Errorf(\"update table flock, plock: %s\", err)\n\t}\n\n\tfor {\n\t\tbeans := session2{Sid: m.sid, Expire: m.expireTime(), Info: sinfo}\n\t\tif update {\n\t\t\treturn m.txn(func(s *xorm.Session) error {","sourceCodeStart":750,"sourceCodeEnd":786,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/sql.go#L750-L786","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Grant CREATE/ALTER privileges so the one-time schema upgrade can complete","Run the mount once with an account that has DDL rights; afterwards regular DML rights suffice","Back up metadata (juicefs dump) before the upgrade and check the wrapped error for the failing table","Ensure no other mount is concurrently migrating the same schema"],"exampleFix":"-- before\nGRANT SELECT, INSERT, UPDATE, DELETE ON jfs.* TO 'jfs'@'%';\n-- after\nGRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER ON jfs.* TO 'jfs'@'%';","handlingStrategy":"validation","validationCode":"// Verify DDL rights before mounting a legacy volume\nSELECT COUNT(*) FROM information_schema.schema_privileges\nWHERE grantee LIKE \"'jfs'%\" AND privilege_type IN ('CREATE','ALTER');","typeGuard":null,"tryCatchPattern":"if err := m.Open(sqlURL); err != nil {\n    log.Fatalf(\"legacy schema upgrade failed, grant DDL rights and retry: %v\", err)\n}","preventionTips":["Take juicefs dump backup before major version upgrades","Upgrade schema once with a privileged account","Mount only one client during migration"],"tags":["database","sql","schema-upgrade","legacy","session"],"backgroundTag":"database-write-failed","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}