{"record":{"id":"786eca35c2488002","repo":"juicedata/juicefs","slug":"session-not-found-d","errorCode":null,"errorMessage":"session not found: %d","messagePattern":"session not found: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/redis.go","lineNumber":599,"sourceCode":"\t\t\t\t} else {\n\t\t\t\t\ts.Plocks = append(s.Plocks, Plock{Ino(inode), owner, loadLocks([]byte(v))})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn &s, nil\n}\n\nfunc (m *redisMeta) GetSession(sid uint64, detail bool) (*Session, error) {\n\tvar legacy bool\n\tkey := strconv.FormatUint(sid, 10)\n\tscore, err := m.rdb.ZScore(Background(), m.allSessions(), key).Result()\n\tif err == redis.Nil {\n\t\tlegacy = true\n\t\tscore, err = m.rdb.ZScore(Background(), legacySessions, key).Result()\n\t}\n\tif err == redis.Nil {\n\t\terr = fmt.Errorf(\"session not found: %d\", sid)\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ts, err := m.getSession(key, detail)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\ts.Expire = time.Unix(int64(score), 0)\n\tif legacy {\n\t\ts.Expire = s.Expire.Add(time.Minute * 5)\n\t}\n\treturn s, nil\n}\n\nfunc (m *redisMeta) ListSessions() ([]*Session, error) {\n\tkeys, err := m.rdb.ZRangeWithScores(Background(), m.allSessions(), 0, -1).Result()\n\tif err != nil {","sourceCodeStart":581,"sourceCodeEnd":617,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/redis.go#L581-L617","documentation":"GetSession first confirms the requested session id exists by checking its score in the `allSessions` sorted set (falling back to the legacy sessions zset for old clients). If neither zset contains the id, it returns \"session not found: <sid>\". This means no live or recorded client session with that id exists in the metadata engine.","triggerScenarios":"Calling `juicefs status <meta-url> --session <sid>` (GetSession) with a session id that was never created, already exited and was cleaned up, belongs to a different volume/meta-URL, or was typed incorrectly (e.g. using the mount's PID instead of the session id).","commonSituations":"1) User asks for a session that already unmounted/crashed and was removed by the stale-session cleanup (`juicefs gc`/`rmr`). 2) Querying the wrong Redis DB/URL than the one the mount used. 3) Copying the wrong number from `juicefs status` output (sids are listed under the Sessions section). 4) Different volume: sessions are per-metadata-engine.","solutions":["List the valid sessions first with `juicefs status <meta-url>` and use an id from the Sessions section.","Confirm you're pointing at the same metadata URL/DB the mount used (compare with the mount command or `juicefs status` volume output).","If the session exited, the record is gone by design — inspect mount logs or use `--session` while the client is still running.","If you expect a live session, check the client process is still up (`ps aux | grep juicefs`) and hasn't been cleaned as stale."],"exampleFix":"// before\n$ juicefs status sqlite3://test.db --session 999\n   session not found: 999\n// after\n$ juicefs status sqlite3://test.db          # list sessions, pick real sid\n$ juicefs status sqlite3://test.db --session 42","handlingStrategy":"validation","validationCode":"// Confirm the session id exists before calling GetSession\n$ juicefs status \"$META_URL\" | grep -A20 Sessions\n# use a sid printed there; sessions vanish after unmount/cleanup","typeGuard":null,"tryCatchPattern":"sess, err := metaCli.GetSession(sid, false)\nif err != nil {\n\tif strings.Contains(err.Error(), \"session not found\") {\n\t\treturn fmt.Errorf(\"session %d is not live; run `juicefs status` to list current sessions\", sid)\n\t}\n\treturn err\n}","preventionTips":["Always list sessions with `juicefs status <meta-url>` first instead of guessing ids.","Remember session records are removed when a client unmounts or is cleaned as stale — capture them while the mount is live.","Verify the metadata URL/DB matches the one the mount used.","Don't confuse the session id with PIDs or inode numbers from other command output.","Check the client process is still running if you expect the session to exist."],"tags":["redis","session","not-found","cli"],"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"}