{"record":{"id":"ab9502a704758c04","repo":"juicedata/juicefs","slug":"create-table-session2-sustaind-delfile-s","errorCode":null,"errorMessage":"create table session2, sustaind, delfile: %s","messagePattern":"create table session2, sustaind, delfile: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/sql.go","lineNumber":592,"sourceCode":"\t}\n\treturn err\n}\n\nfunc (m *dbMeta) syncAllTables() error {\n\tif err := m.syncTable(new(setting), new(counter)); err != nil {\n\t\treturn fmt.Errorf(\"create table setting, counter: %s\", err)\n\t}\n\tif err := m.syncTable(new(edge)); err != nil {\n\t\treturn fmt.Errorf(\"create table edge: %s\", err)\n\t}\n\tif err := m.syncTable(new(node), new(symlink), new(xattr)); err != nil {\n\t\treturn fmt.Errorf(\"create table node, symlink, xattr: %s\", err)\n\t}\n\tif err := m.syncTable(new(chunk), new(sliceRef), new(delslices)); err != nil {\n\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)","sourceCodeStart":574,"sourceCodeEnd":610,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/sql.go#L574-L610","documentation":"syncAllTables (pkg/meta/sql.go:591) creates/auto-migrates the `session2`, `sustained`, and `delfile` tables via xorm Sync2; failure is wrapped as \"create table session2, sustaind, delfile: %s\". These tables track active client sessions, sustained (open) files, and pending deletions. DDL failure aborts initialization; note the message says 'sustaind' (historical spelling) for the `sustained` table.","triggerScenarios":"Metadata engine initialization when Sync2 on session2/sustained/delfile fails: privileges, storage, connection loss, or an existing table with conflicting column types from an older schema.","commonSituations":"Old volumes where session2 schema changed between JuiceFS versions and ALTER fails; DB user restricted to DML only; transient network drop during long-running init.","solutions":["Read the wrapped driver error to identify privilege, storage, or schema conflict and address that root cause.","Ensure the user has CREATE/ALTER privileges on the schema.","If upgrading from an old version, back up and check the session2 table schema; allow Sync2 to migrate or manually drop corrupt leftovers.","Retry the init after transient connection errors; Sync2 is idempotent.","Check the DB server log for the detailed DDL failure reason."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Preflight: ensure session tables are either absent or migrateable\n// MySQL:\n//   SHOW TABLES LIKE 'jfs_session2';\n//   SHOW GRANTS FOR CURRENT_USER();  -- CREATE + ALTER required\n// If present and old, take a metadata backup (juicefs dump) before upgrading.","typeGuard":null,"tryCatchPattern":"if err := initMeta(); err != nil {\n    if strings.Contains(err.Error(), \"create table session2, sustaind, delfile\") {\n        return fmt.Errorf(\"session table migration failed; check grants/schema: %w\", err)\n    }\n    return err\n}","preventionTips":["Read the release notes when upgrading JuiceFS: session2 schema changes require ALTER rights.","Keep a dedicated DB role with persistent CREATE/ALTER grants for the metadata schema.","Retry init on transient errors — the sequence is idempotent.","Watch the DB error log during init for the underlying DDL failure detail."],"tags":["database","schema-migration","ddl","sessions"],"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-14T05:17:10.506Z"}