{"record":{"id":"a7b0a3a13e4d26af","repo":"juicedata/juicefs","slug":"session-not-found-d-a7b0a3","errorCode":null,"errorMessage":"session not found: %d","messagePattern":"session not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/sql.go","lineNumber":904,"sourceCode":"\t\t\tif ok, err = ses.Get(&row); err != nil {\n\t\t\t\treturn err\n\t\t\t} else if ok {\n\t\t\t\ts, err = m.getSession(&row, detail)\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\tif ok, err := ses.IsTableExist(&session{}); err != nil {\n\t\t\treturn err\n\t\t} else if ok {\n\t\t\trow := session{Sid: sid}\n\t\t\tif ok, err = ses.Get(&row); err != nil {\n\t\t\t\treturn err\n\t\t\t} else if ok {\n\t\t\t\ts, err = m.getSession(&row, detail)\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn fmt.Errorf(\"session not found: %d\", sid)\n\t})\n\treturn\n}\n\nfunc (m *dbMeta) ListSessions() ([]*Session, error) {\n\tvar sessions []*Session\n\terr := m.roTxn(Background(), func(ses *xorm.Session) error {\n\t\tif ok, err := ses.IsTableExist(&session2{}); err != nil {\n\t\t\treturn err\n\t\t} else if ok {\n\t\t\tvar rows []session2\n\t\t\tif err = ses.Find(&rows); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tsessions = make([]*Session, 0, len(rows))\n\t\t\tfor i := range rows {\n\t\t\t\ts, err := m.getSession(&rows[i], false)\n\t\t\t\tif err != nil {","sourceCodeStart":886,"sourceCodeEnd":922,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/sql.go#L886-L922","documentation":"Returned by dbMeta.GetSession when no row with the given sid exists in either the current `session2` table or the legacy `session` table. The sid refers to a client session (e.g. from a crash recovery prompt or `juicefs status`) that has since been cleaned up or never existed in this metadata engine.","triggerScenarios":"`juicefs status <sid>` with a stale sid after the client disconnected and stale-session cleanup removed it; passing a sid from a different volume/metadata URL; typo'd sid; querying before any client has mounted (legacy `session` table absent).","commonSituations":"Answering 'N) recover / D) delete' prompts from a stale crash dump where the session already exited; copy-pasting sids between dev and prod volumes; cleanup job (juicefs gc / heartbeat expiry) ran between observing and querying the session.","solutions":["Re-run `juicefs status <meta-url>` to list currently live sessions and confirm the sid exists.","If the sid belonged to a dead client, nothing needs recovery — its locks/sustained inodes were already cleaned by stale-session cleanup.","Verify you are querying the same metadata engine URL as the volume the sid came from."],"exampleFix":"// before: juicefs status 42 -> \"session not found: 42\"\n// after: list live sessions first\njuicefs status sqlite3://test.db | grep -w 42   # confirm sid is live before querying detail","handlingStrategy":"validation","validationCode":"// confirm the sid exists before requesting details\nsessions, err := m.ListSessions()\nif err != nil { return err }\nfound := false\nfor _, s := range sessions { if s.Sid == sid { found = true; break } }\nif !found { return fmt.Errorf(\"sid %d is not live on this volume\", sid) }","typeGuard":null,"tryCatchPattern":"s, err := m.GetSession(sid, false)\nif err != nil && strings.Contains(err.Error(), \"session not found\") {\n    logger.Infof(\"session %d already cleaned up; no recovery needed\", sid)\n    return nil\n}","preventionTips":["Always list current sessions (`juicefs status <meta-url>`) instead of caching sids.","Use the same metadata URL as the volume that produced the sid.","Remember stale sessions expire via heartbeat — act on crash prompts promptly."],"tags":["session","not-found","metadata"],"backgroundTag":"record-not-found","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"}