{"record":{"id":"9014305df99f30f1","repo":"juicedata/juicefs","slug":"scan-trash-slices-s","errorCode":null,"errorMessage":"scan trash slices: %s","messagePattern":"scan trash slices: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/gc.go","lineNumber":209,"sourceCode":"\t\t} else {\n\t\t\tlogger.Errorf(\"compact all chunks: %s\", st)\n\t\t}\n\t\tbar.Done()\n\t\tspin.Done()\n\t} else {\n\t\tm.OnMsg(meta.CompactChunk, func(args ...interface{}) error {\n\t\t\treturn nil // ignore compaction\n\t\t})\n\t}\n\tif delFlag {\n\t\tif st := m.CleanupSlices(c); st != 0 {\n\t\t\tlogger.Fatalf(\"cleanup slices: %s\", st)\n\t\t}\n\t}\n\n\tstats := newGcStats(progress, extSortDir != \"\", delSpin, cleanedFileSpin)\n\tif err := scanTrashSlices(c, m, stats, delFlag, edge); err != nil {\n\t\treturn errors.Errorf(\"scan trash slices: %s\", err)\n\t}\n\tm.WaitDeleteSlices()\n\tm.OnMsg(meta.DeleteSlice, func(args ...interface{}) error {\n\t\treturn errors.New(\"stop deleting slice\")\n\t})\n\n\tvar gcErr error\n\tif extSortDir != \"\" {\n\t\tgcErr = gcExternalSort(c, m, &chunkConf, blob, stats, extSortDir, threads, delFlag, maxMtime)\n\t} else {\n\t\tgcErr = gcInMemory(c, m, &chunkConf, blob, stats, threads, delFlag, maxMtime)\n\t}\n\tif gcErr == nil {\n\t\tstats.finish(delFlag, compact)\n\t}\n\treturn gcErr\n}\n","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/cmd/gc.go#L191-L227","documentation":"Wrapped error from `juicefs gc` when `scanTrashSlices` fails. This phase walks the trash directory in the metadata engine to account for (and optionally delete) slices that already sit in trash; a failure here aborts the whole GC run before block scanning starts. The underlying cause (metadata engine outage, interrupted scan, permission problem) is embedded in the message.","triggerScenarios":"Running `juicefs gc` when the metadata engine (Redis/SQL/TiKV) errors while listing trash slices — e.g. engine restart mid-scan, connection drop, trash key iteration timeout, or an internal scan error returned by m.ScanTrash-like logic inside scanTrashSlices.","commonSituations":"Redis evicted keys or restarted during a long GC; PostgreSQL connection pool exhausted; network partition between the client and the metadata engine; running GC against a volume while another client holds conflicting locks; using an old client against a newer metadata layout.","solutions":["Check the wrapped root cause after 'scan trash slices:' and verify the metadata engine is reachable and healthy (redis-cli ping / DB connect test).","Re-run `juicefs gc` once the metadata engine is stable; transient engine errors are the most common trigger.","Reduce concurrency (`--threads`) if the engine is timing out under load.","Verify client version matches the metadata engine version (mixed versions can fail scans); upgrade the client if needed.","Enable `--debug` logging to capture the full engine error code."],"exampleFix":"// before\njuicefs gc --threads 100 redis://prod:6379/1\n// after (reduce load and retry after engine check)\nredis-cli -h prod ping\njuicefs gc --threads 8 redis://prod:6379/1","handlingStrategy":"retry","validationCode":"// before gc: verify metadata engine reachability\nif err := m.Shutdown(0); err == nil { /* placeholder */ }\n// practical: run 'juicefs status $META_URL' and require exit code 0","typeGuard":null,"tryCatchPattern":"// in Go wrapper around the CLI\nout, err := exec.Command(\"juicefs\", \"gc\", metaURL).CombinedOutput()\nif err != nil && strings.Contains(string(out), \"scan trash slices:\") {\n    // inspect embedded engine error, back off and retry\n}","preventionTips":["Monitor metadata engine health before maintenance windows","Schedule GC during low-traffic periods","Keep client and metadata engine versions aligned","Use --threads sized to engine capacity"],"tags":["go","metadata","gc","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-14T00:17:10.932Z"}