{"record":{"id":"17848f8682484154","repo":"juicedata/juicefs","slug":"create-table-delegationtoken-s","errorCode":null,"errorMessage":"create table delegationToken: %s","messagePattern":"create table delegationToken: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/sql.go","lineNumber":607,"sourceCode":"\t\treturn fmt.Errorf(\"create table chunk, chunk_ref, delslices: %s\", err)\n\t}\n\tif err := m.syncTable(new(session2), new(sustained), new(delfile)); err != nil {\n\t\treturn fmt.Errorf(\"create table session2, sustaind, delfile: %s\", err)\n\t}\n\tif err := m.syncTable(new(flock), new(plock), new(dirQuota), new(userGroupQuota)); err != nil {\n\t\treturn fmt.Errorf(\"create table flock, plock, dirQuota, userGroupQuota: %s\", err)\n\t}\n\tif err := m.syncTable(new(dirStats)); err != nil {\n\t\treturn fmt.Errorf(\"create table dirStats: %s\", err)\n\t}\n\tif err := m.syncTable(new(detachedNode)); err != nil {\n\t\treturn fmt.Errorf(\"create table detachedNode: %s\", err)\n\t}\n\tif err := m.syncTable(new(acl)); err != nil {\n\t\treturn fmt.Errorf(\"create table acl: %s\", err)\n\t}\n\tif err := m.syncTable(new(delegationToken)); err != nil {\n\t\treturn fmt.Errorf(\"create table delegationToken: %s\", err)\n\t}\n\tif err := m.syncTable(new(changeLog)); err != nil {\n\t\treturn fmt.Errorf(\"create table changeLog: %s\", err)\n\t}\n\treturn nil\n}\n\nfunc (m *dbMeta) doInit(format *Format, force bool) error {\n\tif err := m.syncAllTables(); err != nil {\n\t\treturn err\n\t}\n\tvar s = setting{Name: \"format\"}\n\tvar ok bool\n\terr := m.simpleTxn(Background(), func(ses *xorm.Session) (err error) {\n\t\tok, err = ses.Get(&s)\n\t\treturn err\n\t})\n\tif err != nil {","sourceCodeStart":589,"sourceCodeEnd":625,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/sql.go#L589-L625","documentation":"During SQL metadata engine initialization (syncAllTables), JuiceFS creates/verifies all metadata tables via xorm's Sync2. If syncing the delegationToken table fails (DDL error from the database), the error is wrapped with this message and returned, aborting mount/format initialization.","triggerScenarios":"juicefs mount or juicefs format against a MySQL/PostgreSQL/SQLite metadata URL when the delegationToken table cannot be created or altered: insufficient DDL privileges, locked schema, unsupported column type migration, or DB connection failure during syncTable.","commonSituations":"DB user lacks CREATE/ALTER privileges; MySQL server offline mid-startup; migrating an old volume whose schema conflicts; read-only database replica used as metadata URL.","solutions":["Grant CREATE, ALTER, INSERT, SELECT, UPDATE, DELETE privileges on the JuiceFS database to the metadata user","Check the DB server is reachable and not in read-only mode","Inspect the wrapped underlying error (%s) for the exact DDL failure and fix the table/schema conflict","Re-run juicefs fsck or mount after fixing privileges; the table sync is idempotent"],"exampleFix":"-- before\nGRANT SELECT, INSERT ON juicefs.* TO 'jfs'@'%';\n-- after\nGRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER ON juicefs.* TO 'jfs'@'%';","handlingStrategy":"validation","validationCode":"// Before mounting, verify DDL rights and DB reachability\nGRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER ON jfs.* TO 'jfs'@'%';\n// test: mysql -u jfs -p -e 'CREATE TABLE jfs.__probe(id INT); DROP TABLE jfs.__probe;' jfs","typeGuard":null,"tryCatchPattern":"// Wrap mount init and surface the wrapped DDL error\nif err := meta.Open(sqlURL); err != nil {\n    log.Fatalf(\"metadata init failed (check DB privileges/connectivity): %v\", err)\n}","preventionTips":["Grant DDL privileges (CREATE/ALTER) to the metadata user up front","Test DB connectivity before mounting","Keep the DB server out of read-only mode","Take a metadata backup before version upgrades"],"tags":["database","sql","schema-migration","mysql","postgresql","sqlite"],"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"}