{"record":{"id":"1814af6e8bfd4e7e","repo":"juicedata/juicefs","slug":"scan-slice","errorCode":null,"errorMessage":"scan slice","messagePattern":"scan slice","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/sql.go","lineNumber":4139,"sourceCode":"\tif scan == nil {\n\t\treturn nil\n\t}\n\tvar refs []sliceRef\n\terr := m.simpleTxn(ctx, func(tx *xorm.Session) error {\n\t\tif ok, err := tx.IsTableExist(&sliceRef{}); err != nil {\n\t\t\treturn err\n\t\t} else if !ok {\n\t\t\treturn nil\n\t\t}\n\t\treturn tx.Where(\"refs <= 0\").Find(&refs)\n\t})\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"scan slice refs\")\n\t}\n\tfor _, ref := range refs {\n\t\tclean, err := scan(ref.Id, ref.Size)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"scan slice\")\n\t\t}\n\t\tif clean {\n\t\t\t// TODO: m.deleteSlice(ref.Id, ref.Size)\n\t\t\t// avoid lint warning\n\t\t\t_ = clean\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (m *dbMeta) scanPendingFiles(ctx Context, scan pendingFileScan) error {\n\tif scan == nil {\n\t\treturn nil\n\t}\n\n\tvar dfs []delfile\n\tif err := m.simpleTxn(ctx, func(s *xorm.Session) error {\n\t\tif ok, err := s.IsTableExist(&delfile{}); err != nil {","sourceCodeStart":4121,"sourceCodeEnd":4157,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/sql.go#L4121-L4157","documentation":"In scanPendingSlices, after slice refs are listed, the user-supplied scan callback is invoked per sliceRef (id, size) to decide whether the slice can be deleted. Any error returned by that callback is wrapped as \"scan slice\" and aborts the pending-slice scan.","triggerScenarios":"`juicefs gc --delete-slices` on SQL metadata where the per-slice scan callback (checking object storage / slice state) returns an error for a given slice id.","commonSituations":"Object storage unreachable or returning errors during gc; a sliceRef row pointing to inconsistent state; rate limiting or timeouts on the object store during large gc runs.","solutions":["Check object storage connectivity and credentials, then re-run `juicefs gc`","Inspect the wrapped cause to find the failing slice and object store error","Re-run gc after object store issues resolve; the scan restarts from the ref list","Verify no manual deletion of chunks happened out-of-band (use `juicefs gc` instead of deleting objects directly)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// verify object storage is reachable before gc\n_, err := osClient.BucketExists(bucket)","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"scan slice\") {\n    // cause is from the scan callback (usually object storage); fix and re-run gc\n}","preventionTips":["Check object storage credentials/connectivity before gc","Avoid out-of-band deletion of objects in the bucket","Handle object-store rate limits; throttle large gc runs"],"tags":["gc","object-storage","sql"],"backgroundTag":"api-request-failed","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}