juicedata/juicefs · error
find plock %d: %s
Error message
find plock %d: %s
What it means
Thrown by dbMeta.getSession (detail mode) when the SELECT of `plock` rows (POSIX byte-range locks held by the session) fails. It is the third leg of the detail aggregation alongside sustained and flock queries and aborts the whole session detail on error.
Source
Thrown at pkg/meta/sql.go:865
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
}
}
return &s, nil
}
func (m *dbMeta) GetSession(sid uint64, detail bool) (s *Session, err error) {
err = m.roTxn(Background(), func(ses *xorm.Session) error {
if ok, err := ses.IsTableExist(&session2{}); err != nil {
return errView on GitHub (pinned to c9a67b23e8)
Solutions
- Address the wrapped underlying SQL error shown after the colon.
- Verify plock table integrity and schema against the current client version.
- Retry the read-only session-detail query once the database is stable.
Example fix
// before: "find plock 42: Error 2013: Lost connection to MySQL server" // after: raise wait_timeout / fix network, then re-run juicefs status mysql://...
Defensive patterns
Strategy: retry
Validate before calling
if _, err := x.QueryString("SELECT sid FROM plock LIMIT 1"); err != nil {
return fmt.Errorf("plock table unreadable: %w", err)
} Try / catch
if err != nil && strings.Contains(err.Error(), "find plock") {
time.Sleep(2 * time.Second)
s, err = m.GetSession(sid, true)
} Prevention
- Increase DB connection timeouts for long-running inspection commands.
- Restore plock.records-corrupting backups only from quiesced snapshots.
- Validate DB schema after any major JuiceFS client upgrade.
When it happens
Trigger: Session-detail listing while the plock table read fails: missing table, dropped connection, row/record corruption causing scan errors, or DB-level lock timeout.
Common situations: Schema mismatch from mixed client versions; long-running `juicefs status` hitting a MySQL wait_timeout; corrupted plock.records blob after a crashy backup restore.
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 flock %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/fb90dd6ccac73535.
Report an issue: GitHub.