{"record":{"id":"1a09bc15d1f4a7f9","repo":"juicedata/juicefs","slug":"scan-slices-s","errorCode":null,"errorMessage":"scan slices: %s","messagePattern":"scan slices: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/gc_external.go","lineNumber":152,"sourceCode":"\t\tmetaSliceSpin.Increment()\n\t\tvar state uint8\n\t\tswitch ino {\n\t\tcase 0:\n\t\t\tstate = gcStatePending\n\t\tcase 1:\n\t\t\tstate = gcStateTrash\n\t\tdefault:\n\t\t\tstate = gcStateUsed\n\t\t}\n\t\tselect {\n\t\tcase output <- gcMetaRecord{sliceID: s.Id, size: s.Size, state: state}:\n\t\t\treturn nil\n\t\tcase <-c.Done():\n\t\t\treturn c.Err()\n\t\t}\n\t})\n\tif st != 0 {\n\t\treturn errors.Errorf(\"scan slices: %s\", st)\n\t}\n\treturn nil\n}\n\nfunc scanGcObjectRecords(ctx context.Context, blob object.ObjectStorage, output chan<- gcObjectRecord, threads int, hashPrefix bool, maxMtime time.Time, prefixSpin, objScanSpin *utils.Bar, skipped *utils.DoubleSpinner) error {\n\treturn scanGcChunkObjects(ctx, blob, threads, hashPrefix, prefixSpin, func(obj object.Object) error {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn ctx.Err()\n\t\tdefault:\n\t\t}\n\t\tvar ok bool\n\t\tobj, ok = filterGcObject(ctx, blob, obj, maxMtime, objScanSpin, skipped)\n\t\tif !ok {\n\t\t\treturn nil\n\t\t}\n\t\trecord, ok := parseGcObjectRecord(obj)\n\t\tif !ok {","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/gc_external.go#L134-L170","documentation":"Wraps the non-zero meta.Status returned by Meta.ScanSlices when `juicefs gc` (external-sort mode) iterates all slices, including pending ones, in the metadata engine. The scan aborts on context cancellation, metadata engine errors, or callback errors, and the status code is formatted into this message.","triggerScenarios":"Calling `juicefs gc` when the metadata engine (Redis/SQL/KV) returns an error while iterating slices; the meta.Context is cancelled (e.g. another goroutine in the errgroup failed or the process was interrupted); a scan callback returns an error (e.g. sorter input failure).","commonSituations":"Redis/MySQL connection drops mid-gc; gc interrupted by Ctrl-C; one concurrent producer (object scan) fails causing meta context cancellation via errgroup; metadata backend timeouts under heavy load.","solutions":["Decode the status code in the message and check connectivity/health of the metadata engine (e.g. `redis-cli ping`, `mysql -e 'select 1'`)","Re-run the gc command; transient engine/network errors often resolve on retry","Look for a sibling 'produce meta records'/'produce object records' error in the log that caused context cancellation","Reduce gc concurrency/threads if the engine is timing out under scan load"],"exampleFix":"// before\njuicefs gc --threads 64 redis://prod-redis:6379/1   # engine times out\n// after\njuicefs gc --threads 8 redis://prod-redis:6379/1    # lighter scan load","handlingStrategy":"retry","validationCode":"if err := pingMetadataEngine(metaURL); err != nil { return fmt.Errorf(\"metadata engine unreachable: %w\", err) } // e.g. redis-cli PING, MySQL SELECT 1","typeGuard":null,"tryCatchPattern":"if err := gcExternalSort(...); err != nil {\n\tif isTransient(err) { /* retry with backoff */ }\n\tlog.Printf(\"gc scan failed: %v — check metadata engine health\", err)\n}","preventionTips":["Check metadata engine health before starting gc","Avoid interrupting gc mid-scan; use modest thread counts","Monitor engine connection logs during large gc runs"],"tags":["gc","metadata","scan","redis","database"],"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"}