{"record":{"id":"b8cba517b7b191ba","repo":"juicedata/juicefs","slug":"create-table-edge-s","errorCode":null,"errorMessage":"create table edge: %s","messagePattern":"create table edge: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/sql.go","lineNumber":583,"sourceCode":"\t\t}\n\t\treturn err\n\t})\n}\n\nfunc (m *dbMeta) syncTable(beans ...interface{}) error {\n\terr := m.db.Sync2(beans...)\n\tif err != nil && strings.Contains(err.Error(), \"Duplicate key\") {\n\t\terr = nil\n\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)","sourceCodeStart":565,"sourceCodeEnd":601,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/sql.go#L565-L601","documentation":"syncAllTables (pkg/meta/sql.go:582) calls syncTable(new(edge)) to create/auto-migrate the `edge` table via xorm Sync2; on failure the error is wrapped as \"create table edge: %s\". The edge table stores directory entries, so this failure aborts metadata engine initialization. Duplicate-key errors from concurrent creation are already tolerated by syncTable; any other DDL error surfaces here.","triggerScenarios":"Initializing a SQL metadata engine when Sync2 on the edge table fails: privilege or storage problems, an existing edge table with a conflicting/incompatible schema, or a driver-specific DDL limitation.","commonSituations":"Partial initialization from a previously failed run left a broken edge table; managed DB restricts ALTER; MySQL version too old for the generated column/index syntax used by the table definition.","solutions":["Read the wrapped inner error to identify whether it is a privilege, storage, or schema conflict.","Grant CREATE/ALTER privileges on the schema to the JuiceFS database user.","If a previous failed init left a corrupt edge table, back up then drop it so Sync2 can recreate it.","Check DB server disk space and that the database is not in read-only mode.","Verify the database server version is supported by JuiceFS."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Preflight: confirm DDL rights and that no incompatible 'edge' table exists\n// SQL (adjust prefix):\n//   SHOW CREATE TABLE jfs_edge;      -- MySQL: check schema matches expectations\n//   SELECT has_schema_privilege(current_user, 'public', 'CREATE'); -- PostgreSQL\n// If the privilege call returns false or the table schema is foreign, fix before mounting.","typeGuard":null,"tryCatchPattern":"if err := mount(); err != nil {\n    if strings.Contains(err.Error(), \"create table edge\") {\n        return fmt.Errorf(\"edge table DDL failed; check grants/leftover schema: %w\", err)\n    }\n    return err\n}","preventionTips":["After a failed initialization, inspect and clean up partially created tables before retrying.","Verify DB server version compatibility with the JuiceFS release during upgrades.","Ensure adequate disk space and no read-only mode on the DB before init.","Run init as the table-owning role so subsequent Sync2 migrations are permitted."],"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"}