juicedata/juicefs · error
create external sorter: %w
Error message
create external sorter: %w
What it means
New builds a sharded external sorter for GC; if the underlying sorter library fails to construct (returned over errCh), the work directory is removed and 'create external sorter: %w' wraps the root cause. This indicates the external sort infrastructure could not be initialized, e.g. work-dir or writer failures.
Source
Thrown at pkg/utils/extsort/sharded.go:80
input := make(chan T, cfg.Threads*128)
sorter, _, errCh := lanratextsort.Generic(
input,
codec.FromBytes,
codec.ToBytes,
codec.Compare,
&lanratextsort.Config{
ChunkSize: defaultChunkSize,
NumWorkers: cfg.Threads,
ChanBuffSize: cfg.Threads,
SortedChanBuffSize: cfg.Threads * 32,
TempFilesDir: workDir,
Checksum: cfg.Checksum,
},
)
if sorter == nil {
err := <-errCh
_ = os.RemoveAll(workDir)
return nil, fmt.Errorf("create external sorter: %w", err)
}
s := &Sorter[T]{input: input, sorter: sorter, errCh: errCh, workDir: workDir}
go sorter.Sort(ctx)
return s, nil
}
func (s *Sorter[T]) Input() chan<- T {
return s.input
}
func (s *Sorter[T]) CloseInput() {
close(s.input)
}
func (s *Sorter[T]) Next(ctx context.Context) (T, bool, error) {
return s.sorter.Next(ctx)
}
View on GitHub (pinned to c9a67b23e8)
Solutions
- Read the wrapped root cause (%w) for the actual failure
- Ensure the work/temp directory exists and is writable with sufficient space
- Set TMPDIR to a larger writable location
- Re-run GC after freeing disk space
Defensive patterns
Strategy: fallback
Validate before calling
if st, err := os.Stat(workDirParent); err != nil || !st.IsDir() || unix.Access(workDirParent, unix.W_OK) != nil { fail early } Try / catch
sorter, err := New(...); if err != nil { return fmt.Errorf("gc sorter init: %w", err) } // inspect %w cause Prevention
- Keep adequate free space in TMPDIR
- Run GC as a user with write access to temp dirs
- Monitor disk usage before launching GC
When it happens
Trigger: Calling New (via newGcExternalSorters during GC) when the sorter constructor fails — typically the temp/work directory cannot be created or the sorter factory returns an error.
Common situations: No space or permissions in the temp directory (TMPDIR misconfigured, read-only FS); excessive memory/disk limits in containers blocking sorter spawn.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- space not enough on device
- invalid value for delayed slices %q: %v
- scan trash slices: %s
- list all blocks: %s
- list chunks from %s: %s
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/06f1c5b80ab0d1fa.
Report an issue: GitHub.