{"record":{"id":"a0330c128c9cc172","repo":"juicedata/juicefs","slug":"get-delslices-d","errorCode":null,"errorMessage":"get delslices %d","messagePattern":"get delslices (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/sql.go","lineNumber":4064,"sourceCode":"\t\t\treturn err\n\t\t} else if !ok {\n\t\t\treturn nil\n\t\t}\n\t\treturn tx.Find(&dss)\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\tvar ss []Slice\n\tfor _, ds := range dss {\n\t\tvar claimed bool\n\t\terr = m.txn(func(tx *xorm.Session) error {\n\t\t\tclaimed = false\n\t\t\tss = ss[:0]\n\t\t\tdel := delslices{Id: ds.Id}\n\t\t\tfound, err := tx.Get(&del)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrapf(err, \"get delslices %d\", ds.Id)\n\t\t\t}\n\t\t\tif !found {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tm.decodeDelayedSlices(del.Slices, &ss)\n\t\t\tclean, err := scan(ss, del.Deleted)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif !clean {\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\t// Deleting the delayed row claims cleanup; rollback restores it on failure.\n\t\t\taffected, err := tx.Delete(&delslices{Id: del.Id})\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrapf(err, \"claim delayed slice %d\", del.Id)\n\t\t\t}","sourceCodeStart":4046,"sourceCodeEnd":4082,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/sql.go#L4046-L4082","documentation":"In scanTrashSlices (run by `juicefs gc` trash slice cleanup), each delayed-slices row is re-read inside a transaction before cleanup. If the SELECT of the delslices row by Id fails at the database level, the error is wrapped as \"get delslices %d\" and gc stops for that row.","triggerScenarios":"`juicefs gc --delete-slices` (or trash slice scan) on a SQL volume while re-reading a delslices row, and the underlying SELECT fails due to connection loss, lock wait timeout, or table corruption.","commonSituations":"Long-running gc against MySQL/Postgres with connection idle timeouts; DB failover mid-scan; heavy write load causing lock waits; proxy/LB dropping long transactions.","solutions":["Re-run `juicefs gc`; the scan is resumable since rows are processed one by one","Increase DB connection/idle timeouts or use a more stable direct connection","Check the wrapped cause for lock waits and run gc during low-traffic windows","If a specific row is corrupt, verify table integrity (CHECK TABLE / VACUUM)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// check DB reachability before a long gc run\ndb.Ping()","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"get delslices\") {\n    // transient DB failure: wait and re-run `juicefs gc`\n}","preventionTips":["Run gc with direct, stable DB connections (avoid idle-timeout proxies)","Schedule gc in low-traffic windows","Monitor DB for lock-wait/deadlock errors during maintenance"],"tags":["database","gc","sql"],"backgroundTag":"sql-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"}