{"record":{"id":"0e4e5324c0c1ffc0","repo":"juicedata/juicefs","slug":"find-sustained-d-s","errorCode":null,"errorMessage":"find sustained %d: %s","messagePattern":"find sustained (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/sql.go","lineNumber":849,"sourceCode":"\t\tinfo = row.Info\n\t\tif info == nil { // legacy client has no info\n\t\t\tinfo = []byte(\"{}\")\n\t\t}\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"invalid type: %T\", row)\n\t}\n\tif err := json.Unmarshal(info, &s); err != nil {\n\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))","sourceCodeStart":831,"sourceCodeEnd":867,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/sql.go#L831-L867","documentation":"Thrown by dbMeta.getSession (detail mode) when querying the `sustained` table for files held open by the session fails. GetSession with detail=true aggregates sustained inodes, flock, and plock rows; a SQL error on the sustained lookup aborts session detail retrieval.","triggerScenarios":"`juicefs status <meta-url>` or other session-detail listing while the sustained table is missing/corrupt, the DB connection drops mid read-only transaction, or a lock/timeout occurs on the table.","commonSituations":"Schema partially migrated (sustained table dropped by an old client's cleanup); MySQL server gone away during a long status listing; table-level corruption on SQLite volumes.","solutions":["Read the wrapped %s detail for the underlying SQL driver error and address it.","Verify the sustained table exists and matches the current schema (compare against pkg/meta/sql.go bean definitions).","Reconnect/retry once the database is healthy; session detail queries are read-only and safe to repeat."],"exampleFix":"// before: \"find sustained 42: Error 1146: Table 'jfs.sustained' doesn't exist\"\n// after: restore the table via a full-featured client that auto-creates missing tables, then retry\njuicefs status mysql://...   # after re-ensuring schema","handlingStrategy":"retry","validationCode":"// verify required tables exist before detail queries\ncount, err := x.Where(\"name = 'sustained'\").Count(&tables)\nif err != nil || count == 0 {\n    return fmt.Errorf(\"sustained table missing\")\n}","typeGuard":null,"tryCatchPattern":"s, err := m.GetSession(sid, true)\nif err != nil && strings.Contains(err.Error(), \"find sustained\") {\n    time.Sleep(time.Second)\n    s, err = m.GetSession(sid, true) // read-only query, safe to retry\n}","preventionTips":["Keep at least one current-version client mounted so schema stays migrated.","Watch DB 'server has gone away' logs; tune wait_timeout for long status listings.","Run integrity checks (CHECK TABLE / PRAGMA integrity_check) routinely."],"tags":["database","query","session","metadata"],"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"}