juicedata/juicefs · error
find flock %d: %s
Error message
find flock %d: %s
What it means
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).
Source
Thrown at pkg/meta/sql.go:857
return nil, fmt.Errorf("corrupted session info; json error: %s", err)
}
if detail {
var (
srows []sustained
frows []flock
prows []plock
)
err := m.roTxn(Background(), func(ses *xorm.Session) error {
if err := ses.Find(&srows, &sustained{Sid: s.Sid}); err != nil {
return fmt.Errorf("find sustained %d: %s", s.Sid, err)
}
s.Sustained = make([]Ino, 0, len(srows))
for _, srow := range srows {
s.Sustained = append(s.Sustained, srow.Inode)
}
if err := ses.Find(&frows, &flock{Sid: s.Sid}); err != nil {
return fmt.Errorf("find flock %d: %s", s.Sid, err)
}
s.Flocks = make([]Flock, 0, len(frows))
for _, frow := range frows {
s.Flocks = append(s.Flocks, Flock{frow.Inode, uint64(frow.Owner), string(frow.Ltype)})
}
if err := ses.Find(&prows, &plock{Sid: s.Sid}); err != nil {
return fmt.Errorf("find plock %d: %s", s.Sid, err)
}
s.Plocks = make([]Plock, 0, len(prows))
for _, prow := range prows {
s.Plocks = append(s.Plocks, Plock{prow.Inode, uint64(prow.Owner), loadLocks(prow.Records)})
}
return nil
})
if err != nil {
return nil, err
}View on GitHub (pinned to c9a67b23e8)
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.
Example fix
// before: "find flock 42: driver: bad connection" // after: reconnect and re-run mysqladmin -h dbhost ping && juicefs status mysql://...
Defensive patterns
Strategy: retry
Validate before calling
if _, err := x.QueryString("SELECT 1 FROM flock LIMIT 1"); err != nil {
return fmt.Errorf("flock table unreadable: %w", err)
} Try / catch
if err != nil && strings.Contains(err.Error(), "find flock") {
if dbErr := reconnect(); dbErr != nil { return dbErr }
s, err = m.GetSession(sid, true)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Partially migrated schema after client version mix; MySQL 'server has gone away' during `juicefs status` on a busy volume; SQLite file corruption.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- find sustained %d: %s
- find plock %d: %s
- get session ID: %s
- update table session2, delslices, dirstats, detachedNode, di
- get session ID: %s
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/a24d4f02692b379e.
Report an issue: GitHub.