{"record":{"id":"9191af599d71fa12","repo":"juicedata/juicefs","slug":"create-table-detachednode-s","errorCode":null,"errorMessage":"create table detachedNode: %s","messagePattern":"create table detachedNode: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/sql.go","lineNumber":601,"sourceCode":"\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)\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\"}","sourceCodeStart":583,"sourceCodeEnd":619,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/sql.go#L583-L619","documentation":"syncAllTables (pkg/meta/sql.go:600) creates/auto-migrates the `detachedNode` table via xorm Sync2; failure is wrapped as \"create table detachedNode: %s\". detachedNode tracks inodes detached from the directory tree (e.g. removed while still open / pending operations). Failure aborts metadata engine initialization.","triggerScenarios":"Metadata engine initialization when Sync2 on detachedNode fails: same class of DDL problems — privileges, storage, connection drop, or conflicting pre-existing table.","commonSituations":"Newer JuiceFS clients adding this table to an older volume while the DB user lacks CREATE rights; read-only managed database tier; hitting connection limits late in the init sequence.","solutions":["Read the wrapped driver error and fix the root cause (grant, space, connectivity).","Ensure the DB user has CREATE privilege — this table is added by newer versions and requires fresh DDL on old volumes.","Retry after transient connection errors; earlier tables already exist and Sync2 skips them.","Verify the database accepts DDL from this host/user (managed-DB restriction lists).","Back up and remove any conflicting table named detachedNode."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Preflight on legacy volumes upgrading to versions that add detachedNode:\n//   SHOW GRANTS FOR CURRENT_USER();  -- CREATE must be present\n//   SHOW TABLES LIKE 'jfs_detachedNode';  -- absence is expected on first upgrade","typeGuard":null,"tryCatchPattern":"if err := initMeta(); err != nil {\n    if strings.Contains(err.Error(), \"create table detachedNode\") {\n        return fmt.Errorf(\"detachedNode DDL failed; new table creation requires CREATE privilege: %w\", err)\n    }\n    return err\n}","preventionTips":["When upgrading JuiceFS, run the first mount with a fully privileged DB user so new tables can be created.","Keep CREATE grants even after initial format — later versions add tables like detachedNode.","Confirm managed-DB restriction lists do not block DDL from the JuiceFS host.","Retry once after transient connection errors before deeper debugging."],"tags":["database","schema-migration","ddl"],"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"}