{"record":{"id":"fb90dd6ccac73535","repo":"juicedata/juicefs","slug":"find-plock-d-s","errorCode":null,"errorMessage":"find plock %d: %s","messagePattern":"find plock (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/sql.go","lineNumber":865,"sourceCode":"\t\terr := m.roTxn(Background(), func(ses *xorm.Session) error {\n\t\t\tif err := ses.Find(&srows, &sustained{Sid: s.Sid}); err != nil {\n\t\t\t\treturn fmt.Errorf(\"find sustained %d: %s\", s.Sid, err)\n\t\t\t}\n\t\t\ts.Sustained = make([]Ino, 0, len(srows))\n\t\t\tfor _, srow := range srows {\n\t\t\t\ts.Sustained = append(s.Sustained, srow.Inode)\n\t\t\t}\n\n\t\t\tif err := ses.Find(&frows, &flock{Sid: s.Sid}); err != nil {\n\t\t\t\treturn fmt.Errorf(\"find flock %d: %s\", s.Sid, err)\n\t\t\t}\n\t\t\ts.Flocks = make([]Flock, 0, len(frows))\n\t\t\tfor _, frow := range frows {\n\t\t\t\ts.Flocks = append(s.Flocks, Flock{frow.Inode, uint64(frow.Owner), string(frow.Ltype)})\n\t\t\t}\n\n\t\t\tif err := ses.Find(&prows, &plock{Sid: s.Sid}); err != nil {\n\t\t\t\treturn fmt.Errorf(\"find plock %d: %s\", s.Sid, err)\n\t\t\t}\n\t\t\ts.Plocks = make([]Plock, 0, len(prows))\n\t\t\tfor _, prow := range prows {\n\t\t\t\ts.Plocks = append(s.Plocks, Plock{prow.Inode, uint64(prow.Owner), loadLocks(prow.Records)})\n\t\t\t}\n\t\t\treturn nil\n\t\t})\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\treturn &s, nil\n}\n\nfunc (m *dbMeta) GetSession(sid uint64, detail bool) (s *Session, err error) {\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","sourceCodeStart":847,"sourceCodeEnd":883,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/sql.go#L847-L883","documentation":"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.","triggerScenarios":"Session-detail listing while the plock table read fails: missing table, dropped connection, row/record corruption causing scan errors, or DB-level lock timeout.","commonSituations":"Schema mismatch from mixed client versions; long-running `juicefs status` hitting a MySQL wait_timeout; corrupted plock.records blob after a crashy backup restore.","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."],"exampleFix":"// before: \"find plock 42: Error 2013: Lost connection to MySQL server\"\n// after: raise wait_timeout / fix network, then re-run\njuicefs status mysql://...","handlingStrategy":"retry","validationCode":"if _, err := x.QueryString(\"SELECT sid FROM plock LIMIT 1\"); err != nil {\n    return fmt.Errorf(\"plock table unreadable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"find plock\") {\n    time.Sleep(2 * time.Second)\n    s, err = m.GetSession(sid, true)\n}","preventionTips":["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."],"tags":["database","query","plock","session"],"backgroundTag":"database-query-failed","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"}