{"record":{"id":"bec59828abdd3fdf","repo":"juicedata/juicefs","slug":"create-meta-sorter-s","errorCode":null,"errorMessage":"create meta sorter: %s","messagePattern":"create meta sorter: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/gc_external.go","lineNumber":106,"sourceCode":"\tif sortErr != nil {\n\t\treturn sortErr\n\t}\n\treturn nil\n}\n\nfunc newGcExternalSorters(ctx context.Context, extSortDir string, threads int) (*extsort.Sorter[gcMetaRecord], *extsort.Sorter[gcObjectRecord], error) {\n\tmetaSorter, err := extsort.New(ctx, extsort.Config{\n\t\tWorkDir:  extSortDir,\n\t\tName:     \"gc-meta\",\n\t\tThreads:  threads,\n\t\tChecksum: true,\n\t}, extsort.Codec[gcMetaRecord]{\n\t\tFromBytes: gcMetaRecordFromBytes,\n\t\tToBytes:   gcMetaRecordToBytes,\n\t\tCompare:   compareGcMetaRecord,\n\t})\n\tif err != nil {\n\t\treturn nil, nil, errors.Errorf(\"create meta sorter: %s\", err)\n\t}\n\n\tobjSorter, err := extsort.New(ctx, extsort.Config{\n\t\tWorkDir:  extSortDir,\n\t\tName:     \"gc-object\",\n\t\tThreads:  threads,\n\t\tChecksum: true,\n\t}, extsort.Codec[gcObjectRecord]{\n\t\tFromBytes: gcObjectRecordFromBytes,\n\t\tToBytes:   gcObjectRecordToBytes,\n\t\tCompare:   compareGcObjectRecord,\n\t})\n\tif err != nil {\n\t\tmetaSorter.CloseInput()\n\t\t_ = metaSorter.Done()\n\t\treturn nil, nil, errors.Errorf(\"create object sorter: %s\", err)\n\t}\n\treturn metaSorter, objSorter, nil","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/gc_external.go#L88-L124","documentation":"Wrapped error from newGcExternalSorters when creating the meta record external sorter (extsort.New) fails — before any scan starts. Typical causes are problems with the work directory or sorter config, so GC in external-sort mode cannot proceed and exits early with this message.","triggerScenarios":"`juicefs gc --ext-sort <dir>` where extsort.New fails: the WorkDir doesn't exist or isn't writable, filesystem errors creating the sorter's temp files, or an invalid config (e.g. non-positive threads).","commonSituations":"Passing --ext-sort a path on a read-only or non-existent directory; running in a container with a read-only rootfs; permission-denied on the sort dir; typo in the directory path.","solutions":["Ensure the --ext-sort directory exists and is writable: `mkdir -p <dir> && touch <dir>/.probe`.","Check permissions of the directory for the user running juicefs.","Fix the path typo if the directory doesn't exist.","Avoid read-only mounts/containers for the sort dir; mount a writable volume.","If threads config is suspect, retry with default --threads."],"exampleFix":"// before\njuicefs gc --ext-sort /nonexistent-dir $META\n// after\nmkdir -p /var/jfs-extsort && juicefs gc --ext-sort /var/jfs-extsort $META","handlingStrategy":"validation","validationCode":"DIR=$EXT_SORT_DIR; [ -d \"$DIR\" ] && [ -w \"$DIR\" ] && touch \"$DIR/.probe\" && rm \"$DIR/.probe\" || { echo \"ext-sort dir missing or unwritable: $DIR\"; exit 1; }","typeGuard":null,"tryCatchPattern":"if strings.Contains(out, \"create meta sorter:\") {\n    // ext-sort WorkDir problem: verify path exists and is writable before retry\n}","preventionTips":["Always mkdir and permission-check the --ext-sort directory before running","Avoid read-only mounts for temp sort dirs","Keep --threads at supported defaults unless tuned"],"tags":["go","gc","external-sort","filesystem","config"],"backgroundTag":"file-write-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"}