juicedata/juicefs · error
session not found: %d
Error message
session not found: %d
What it means
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.
Source
Thrown at pkg/meta/redis.go:599
} else {
s.Plocks = append(s.Plocks, Plock{Ino(inode), owner, loadLocks([]byte(v))})
}
}
}
}
return &s, nil
}
func (m *redisMeta) GetSession(sid uint64, detail bool) (*Session, error) {
var legacy bool
key := strconv.FormatUint(sid, 10)
score, err := m.rdb.ZScore(Background(), m.allSessions(), key).Result()
if err == redis.Nil {
legacy = true
score, err = m.rdb.ZScore(Background(), legacySessions, key).Result()
}
if err == redis.Nil {
err = fmt.Errorf("session not found: %d", sid)
}
if err != nil {
return nil, err
}
s, err := m.getSession(key, detail)
if err != nil {
return nil, err
}
s.Expire = time.Unix(int64(score), 0)
if legacy {
s.Expire = s.Expire.Add(time.Minute * 5)
}
return s, nil
}
func (m *redisMeta) ListSessions() ([]*Session, error) {
keys, err := m.rdb.ZRangeWithScores(Background(), m.allSessions(), 0, -1).Result()
if err != nil {View on GitHub (pinned to c9a67b23e8)
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.
Example fix
// before $ juicefs status sqlite3://test.db --session 999 session not found: 999 // after $ juicefs status sqlite3://test.db # list sessions, pick real sid $ juicefs status sqlite3://test.db --session 42
Defensive patterns
Strategy: validation
Validate before calling
// Confirm the session id exists before calling GetSession $ juicefs status "$META_URL" | grep -A20 Sessions # use a sid printed there; sessions vanish after unmount/cleanup
Try / catch
sess, err := metaCli.GetSession(sid, false)
if err != nil {
if strings.Contains(err.Error(), "session not found") {
return fmt.Errorf("session %d is not live; run `juicefs status` to list current sessions", sid)
}
return err
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- new session: %s
- new session %d: %s
- HGet sessionInfos %s: %s
- corrupted session info; json error: %s
- SMembers %s: %s
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/786eca35c2488002.
Report an issue: GitHub.