{"record":{"id":"a24d4f02692b379e","repo":"juicedata/juicefs","slug":"find-flock-d-s","errorCode":null,"errorMessage":"find flock %d: %s","messagePattern":"find flock (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/sql.go","lineNumber":857,"sourceCode":"\t\treturn nil, fmt.Errorf(\"corrupted session info; json error: %s\", err)\n\t}\n\tif detail {\n\t\tvar (\n\t\t\tsrows []sustained\n\t\t\tfrows []flock\n\t\t\tprows []plock\n\t\t)\n\t\terr := m.roTxn(Background(), func(ses *xorm.Session) error {\n\t\t\tif err := ses.Find(&srows, &sustained{Sid: s.Sid}); err != nil {\n\t\t\t\treturn fmt.Errorf(\"find sustained %d: %s\", s.Sid, err)\n\t\t\t}\n\t\t\ts.Sustained = make([]Ino, 0, len(srows))\n\t\t\tfor _, srow := range srows {\n\t\t\t\ts.Sustained = append(s.Sustained, srow.Inode)\n\t\t\t}\n\n\t\t\tif err := ses.Find(&frows, &flock{Sid: s.Sid}); err != nil {\n\t\t\t\treturn fmt.Errorf(\"find flock %d: %s\", s.Sid, err)\n\t\t\t}\n\t\t\ts.Flocks = make([]Flock, 0, len(frows))\n\t\t\tfor _, frow := range frows {\n\t\t\t\ts.Flocks = append(s.Flocks, Flock{frow.Inode, uint64(frow.Owner), string(frow.Ltype)})\n\t\t\t}\n\n\t\t\tif err := ses.Find(&prows, &plock{Sid: s.Sid}); err != nil {\n\t\t\t\treturn fmt.Errorf(\"find plock %d: %s\", s.Sid, err)\n\t\t\t}\n\t\t\ts.Plocks = make([]Plock, 0, len(prows))\n\t\t\tfor _, prow := range prows {\n\t\t\t\ts.Plocks = append(s.Plocks, Plock{prow.Inode, uint64(prow.Owner), loadLocks(prow.Records)})\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}","sourceCodeStart":839,"sourceCodeEnd":875,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/sql.go#L839-L875","documentation":"Thrown by dbMeta.getSession (detail mode) when the SELECT of `flock` rows (POSIX OFD/file locks held by the session) fails. Same aggregation path as the sustained/flock/plock detail queries in GetSession(detail=true).","triggerScenarios":"Session-detail listing while the flock table is missing, corrupted, or the read transaction errors (connection reset, timeout, deadlock). Not related to lock conflicts — purely a SQL read failure.","commonSituations":"Partially migrated schema after client version mix; MySQL 'server has gone away' during `juicefs status` on a busy volume; SQLite file corruption.","solutions":["Inspect the wrapped %s driver error and fix the root cause (connectivity, table integrity).","Confirm the flock table exists with expected columns; run schema checks for the volume's DB.","Retry the session-detail command after the DB is healthy."],"exampleFix":"// before: \"find flock 42: driver: bad connection\"\n// after: reconnect and re-run\nmysqladmin -h dbhost ping && juicefs status mysql://...","handlingStrategy":"retry","validationCode":"if _, err := x.QueryString(\"SELECT 1 FROM flock LIMIT 1\"); err != nil {\n    return fmt.Errorf(\"flock table unreadable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"find flock\") {\n    if dbErr := reconnect(); dbErr != nil { return dbErr }\n    s, err = m.GetSession(sid, true)\n}","preventionTips":["Retry session-detail listings after transient DB errors; they are read-only.","Fix schema drift promptly by running the latest JuiceFS client once.","Enable DB slow/timeout logging to catch issues before status commands hit them."],"tags":["database","query","flock","session"],"backgroundTag":"database-query-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"}