juicedata/juicefs · error
scan slices: %s
Error message
scan slices: %s
What it means
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.
Source
Thrown at cmd/gc_external.go:152
metaSliceSpin.Increment()
var state uint8
switch ino {
case 0:
state = gcStatePending
case 1:
state = gcStateTrash
default:
state = gcStateUsed
}
select {
case output <- gcMetaRecord{sliceID: s.Id, size: s.Size, state: state}:
return nil
case <-c.Done():
return c.Err()
}
})
if st != 0 {
return errors.Errorf("scan slices: %s", st)
}
return nil
}
func 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 {
return scanGcChunkObjects(ctx, blob, threads, hashPrefix, prefixSpin, func(obj object.Object) error {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
var ok bool
obj, ok = filterGcObject(ctx, blob, obj, maxMtime, objScanSpin, skipped)
if !ok {
return nil
}
record, ok := parseGcObjectRecord(obj)
if !ok {View on GitHub (pinned to c9a67b23e8)
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
Example fix
// before juicefs gc --threads 64 redis://prod-redis:6379/1 # engine times out // after juicefs gc --threads 8 redis://prod-redis:6379/1 # lighter scan load
Defensive patterns
Strategy: retry
Validate before calling
if err := pingMetadataEngine(metaURL); err != nil { return fmt.Errorf("metadata engine unreachable: %w", err) } // e.g. redis-cli PING, MySQL SELECT 1 Try / catch
if err := gcExternalSort(...); err != nil {
if isTransient(err) { /* retry with backoff */ }
log.Printf("gc scan failed: %v — check metadata engine health", err)
} Prevention
- Check metadata engine health before starting gc
- Avoid interrupting gc mid-scan; use modest thread counts
- Monitor engine connection logs during large gc runs
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- scan trash slices: %s
- produce meta records: %s
- database %s is used by volume %s
- load setting: %s
- new session: %s
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/1a09bc15d1f4a7f9.
Report an issue: GitHub.