{"record":{"id":"07760d6bedee0fe6","repo":"juicedata/juicefs","slug":"scan-pending-slices","errorCode":null,"errorMessage":"scan pending slices","messagePattern":"scan pending slices","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/meta/redis.go","lineNumber":4202,"sourceCode":"\t\tclose(pendingKeys)\n\t}()\n\n\tfor key := range pendingKeys {\n\t\tps := strings.Split(key[1:], \"_\")\n\t\tif len(ps) != 2 {\n\t\t\treturn fmt.Errorf(\"invalid key %s\", key)\n\t\t}\n\t\tid, err := strconv.ParseUint(ps[0], 10, 64)\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"invalid key %s, fail to parse id\", key)\n\t\t}\n\t\tsize, err := strconv.ParseUint(ps[1], 10, 64)\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"invalid key %s, fail to parse size\", key)\n\t\t}\n\t\tclean, err := scan(id, uint32(size))\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"scan pending slices\")\n\t\t}\n\t\tif clean {\n\t\t\t// TODO: m.deleteSlice(id, uint32(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 *redisMeta) scanPendingFiles(ctx Context, scan pendingFileScan) error {\n\tif scan == nil {\n\t\treturn nil\n\t}\n\n\tvisited := make(map[Ino]bool)\n\tstart := int64(0)\n\tconst batchSize = 1000","sourceCodeStart":4184,"sourceCodeEnd":4220,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/meta/redis.go#L4184-L4220","documentation":"Wraps any failure returned by the scan callback while processing a single pending slice during `juicefs gc` (redisMeta.scanPendingSlices). Once the \"<id>_<size>\" key parsed fine, the scan() function inspects whether the slice's data still exists in object storage; any error from that inspection (metadata lookup, object storage access) is wrapped with this message.","triggerScenarios":"`juicefs gc` processing a valid pending-slice key when scan(id, size) returns an error — e.g. chunk/index lookup against the metadata engine failed or object storage was unreachable during the scan.","commonSituations":"Object storage credentials expired or network outage during GC; metadata engine failures mid-scan; very large pending-slice backlogs timing out.","solutions":["Unwrap the error to see the underlying cause (metadata vs object storage) and fix it.","Re-run `juicefs gc`; the scan is resumable and processes keys individually.","Verify object storage connectivity/credentials with `juicefs gc --dry` or a small sync test.","Reduce GC concurrency or run during off-peak if timeouts are the cause."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Verify object storage reachability before gc:\nout, err := juicefs.Gc(ctx, meta, true /*dry*/)","typeGuard":null,"tryCatchPattern":"err := gc(ctx, meta)\nfor attempt := 0; err != nil && attempt < 3; attempt++ {\n    time.Sleep(backoff(attempt))\n    err = gc(ctx, meta) // resumable: already-cleaned keys are skipped\n}","preventionTips":["Validate object storage credentials with a small sync/rmr test before long GC runs.","Run `juicefs gc --dry` first to surface per-slice issues safely.","Schedule GC off-peak with adequate timeouts.","Keep the pending-slices backlog small by fixing upload failures promptly."],"tags":["go","redis","gc","wrapped-error"],"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-14T00:17:10.932Z"}