{"record":{"id":"faead429cd5f0d96","repo":"juicedata/juicefs","slug":"create-table-flock-plock-dirquota-usergroupquot","errorCode":null,"errorMessage":"create table flock, plock, dirQuota, userGroupQuota: %s","messagePattern":"create table flock, plock, dirQuota, userGroupQuota: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/sql.go","lineNumber":595,"sourceCode":"\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)\n\t}\n\treturn nil\n}","sourceCodeStart":577,"sourceCodeEnd":613,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/sql.go#L577-L613","documentation":"syncAllTables (pkg/meta/sql.go:594) creates/auto-migrates the lock and quota tables `flock`, `plock`, `dirQuota`, and `userGroupQuota` via xorm Sync2; failure is wrapped as \"create table flock, plock, dirQuota, userGroupQuota: %s\". These tables back POSIX locks and directory/user-group quotas. Failure aborts metadata initialization.","triggerScenarios":"Metadata engine initialization when Sync2 on the lock/quota beans fails: DDL privileges missing, storage exhaustion, or a quota table with an incompatible pre-existing schema.","commonSituations":"Tightened DB grants after initial provisioning; managed PostgreSQL with restricted schema ownership (tables owned by another role); disk full on the DB host.","solutions":["Inspect the wrapped inner error (permission denied / disk full / type conflict) and fix the DB-side cause.","Ensure the connecting role owns the schema or has CREATE/ALTER rights on it.","For PostgreSQL, verify search_path points to a schema the user can create tables in.","Free DB storage if exhausted, then re-run initialization.","Back up and drop any incompatible leftover tables of the same names."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Preflight PostgreSQL schema ownership before init\n//   SELECT has_schema_privilege(current_user, 'public', 'CREATE');\n//   SELECT tableowner FROM pg_tables WHERE tablename LIKE '%flock';\n// MySQL: SHOW GRANTS FOR CURRENT_USER(); -- needs CREATE, ALTER, INDEX","typeGuard":null,"tryCatchPattern":"if err := initMeta(); err != nil {\n    if strings.Contains(err.Error(), \"create table flock, plock, dirQuota, userGroupQuota\") {\n        return fmt.Errorf(\"lock/quota table DDL failed; verify schema ownership and grants: %w\", err)\n    }\n    return err\n}","preventionTips":["For PostgreSQL, set search_path to a schema owned by the JuiceFS role (or grant CREATE ON SCHEMA).","Do not downgrade the DB user to read-only after formatting the volume; migrations run at every init.","Monitor DB host disk space; quota tables grow with usage.","Back up before removing or renaming lock/quota tables manually."],"tags":["database","schema-migration","ddl","quota","locks"],"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"}