{"record":{"id":"09f18846378662a1","repo":"juicedata/juicefs","slug":"update-table-flock-plock-s","errorCode":null,"errorMessage":"update table flock, plock: %s","messagePattern":"update table flock, plock: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/sql.go","lineNumber":780,"sourceCode":"}\n\nfunc (m *dbMeta) doNewSession(sinfo []byte, update bool) error {\n\t// add new table\n\terr := m.syncTable(new(session2), new(delslices), new(dirStats), new(detachedNode), new(dirQuota), new(userGroupQuota), new(acl), new(delegationToken), new(changeLog))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"update table session2, delslices, dirstats, detachedNode, dirQuota, userGroupQuota, acl, changeLog: %s\", err)\n\t}\n\t// add node table\n\tif err = m.syncTable(new(node)); err != nil {\n\t\treturn fmt.Errorf(\"update table node: %s\", err)\n\t}\n\t// add primary key\n\tif err = m.syncTable(new(edge), new(chunk), new(xattr), new(sustained)); err != nil {\n\t\treturn fmt.Errorf(\"update table edge, chunk, xattr, sustained: %s\", err)\n\t}\n\t// update the owner from uint64 to int64\n\tif err = m.syncTable(new(flock), new(plock)); err != nil {\n\t\treturn fmt.Errorf(\"update table flock, plock: %s\", err)\n\t}\n\n\tfor {\n\t\tbeans := session2{Sid: m.sid, Expire: m.expireTime(), Info: sinfo}\n\t\tif update {\n\t\t\treturn m.txn(func(s *xorm.Session) error {\n\t\t\t\t_, err = s.Cols(\"expire\", \"info\").Update(&beans, &session2{Sid: beans.Sid})\n\t\t\t\tif err == nil {\n\t\t\t\t\tm.genLog(Background(), s, time.Now().UnixNano(), \"NEWSESSION(%d,%d,%s)\", m.sid, beans.Expire, logEncode(sinfo))\n\t\t\t\t}\n\t\t\t\treturn err\n\t\t\t})\n\t\t} else {\n\t\t\tif err = m.txn(func(s *xorm.Session) error {\n\t\t\t\tif err := mustInsert(s, &beans); err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\tm.genLog(Background(), s, time.Now().UnixNano(), \"NEWSESSION(%d,%d,%s)\", m.sid, beans.Expire, logEncode(sinfo))","sourceCodeStart":762,"sourceCodeEnd":798,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/sql.go#L762-L798","documentation":"Returned by dbMeta.doNewSession when the xorm schema sync of the flock/plock tables fails during session creation. It wraps the DDL error, meaning the SQL metadata engine could not migrate lock tables to the required schema (permissions or DB compatibility issue).","triggerScenarios":"Mounting an old volume when altering flock/plock tables fails — lock table size causes ALTER timeout, missing privileges, or DB connection drop mid-migration.","commonSituations":"Volumes with many stale flock/plock rows from crashed sessions; managed DB with restrictive DDL timeouts; upgrade run concurrently by multiple mount points.","solutions":["Clean stale lock rows (juicefs gc / remove rows for dead sessions) then retry the mount","Grant ALTER privileges and retry with a single mount performing the upgrade","Increase DDL timeouts for large flock/plock tables","Ensure only one client performs the schema upgrade at a time"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"-- Remove locks of dead sessions before upgrade\nDELETE FROM flock WHERE sid NOT IN (SELECT sid FROM session2);","typeGuard":null,"tryCatchPattern":"if err := mount(sqlURL); err != nil {\n    if strings.Contains(err.Error(), \"flock, plock\") {\n        log.Fatalf(\"clean stale lock rows and retry: %v\", err)\n    }\n}","preventionTips":["Run juicefs gc periodically","Ensure single-client schema upgrade","Grant ALTER privileges"],"tags":["database","sql","schema-upgrade","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"}