{"record":{"id":"f5af01e812f49565","repo":"dgraph-io/dgraph","slug":"runrestore-failed-to-reduce","errorCode":null,"errorMessage":"RunRestore failed to reduce","messagePattern":"RunRestore failed to reduce","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"worker/online_restore.go","lineNumber":603,"sourceCode":"\t\t\tWithCompression(ctype).\n\t\t\tWithZSTDCompressionLevel(clevel).\n\t\t\tWithSyncWrites(false).\n\t\t\tWithBlockCacheSize(100 * (1 << 20)).\n\t\t\tWithIndexCacheSize(100 * (1 << 20)).\n\t\t\tWithNumVersionsToKeep(math.MaxInt32).\n\t\t\tWithEncryptionKey(key).\n\t\t\tWithNamespaceOffset(x.NamespaceOffset))\n\t\tif err != nil {\n\t\t\treturn LoadResult{Err: errors.Wrap(err, \"RunRestore failed to open DB\")}\n\t\t}\n\t\tdefer db.Close()\n\n\t\tsw := db.NewStreamWriter()\n\t\tif err := sw.Prepare(); err != nil {\n\t\t\treturn LoadResult{Err: errors.Wrap(err, \"while preparing DB\")}\n\t\t}\n\t\tif err := RunReducer(sw, mapDir); err != nil {\n\t\t\treturn LoadResult{Err: errors.Wrap(err, \"RunRestore failed to reduce\")}\n\t\t}\n\t\tif err := sw.Flush(); err != nil {\n\t\t\treturn LoadResult{Err: errors.Wrap(err, \"while stream writer flush\")}\n\t\t}\n\t\tif err := x.WriteGroupIdFile(pdir, gid); err != nil {\n\t\t\treturn LoadResult{Err: errors.Wrap(err, \"RunRestore failed to write group id file\")}\n\t\t}\n\t}\n\t// TODO: Fix this return value.\n\treturn LoadResult{Version: manifest.ValidReadTs()}\n}\n\nfunc buildPredsForDefaultNamespace(restorePreds []string, fromNamespace uint64) []string {\n\tfiltered := restorePreds[:0]\n\tfor _, pred := range restorePreds {\n\t\tns, attr := x.ParseNamespaceAttr(pred)\n\t\tif fromNamespace == ns {\n\t\t\t// update namespace value to 0","sourceCodeStart":585,"sourceCodeEnd":621,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/worker/online_restore.go#L585-L621","documentation":"This error wraps a failure from RunReducer, which replays the mapped backup files from the temp map directory into the Badger StreamWriter during offline restore. It means the reduce phase (reading sorted map output and streaming KVs into the DB) failed, so the group's post directory is incomplete and the restore is aborted.","triggerScenarios":"RunOfflineRestore fails during RunReducer(sw, mapDir): the temp 'restore-map' directory was deleted or corrupted mid-restore, backup files are truncated/corrupt, the map output fails checksums (wrong --backup_id or mixing backup generations), or the StreamWriter rejects a write (e.g. invalid/oversized key, encryption mismatch).","commonSituations":"TMPDIR/tmp volume too small and cleaned during restore; selecting the wrong --backup_id from a multi-backup location; copying a backup directory incompletely between machines; interrupted network transfer corrupting backup files.","solutions":["Retry the restore to rule out transient disk/TMPDIR issues; do not delete the temp map dir while restoring.","Point TMPDIR to a large local disk (e.g. --tmp with ample space) for big restores.","Verify the backup files are complete: re-download/copy from the backup location and check the manifest.","Confirm the correct --backup_id matching the target DB state is used.","Look at the wrapped inner error in logs to identify the specific KV or map file that failed."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if err := verifyBackupManifest(location, backupId); err != nil {\n\treturn fmt.Errorf(\"backup files incomplete: %v\", err)\n}\nensureDiskFree(os.TempDir(), mapSpaceRequired)","typeGuard":null,"tryCatchPattern":"if err := RunOfflineRestore(...); strings.Contains(err.Error(), \"failed to reduce\") {\n\t// verify backup integrity, enlarge TMPDIR, retry from clean state\n}","preventionTips":["Point TMPDIR at a large local volume before restoring","Verify backup completeness (manifest + all generation files) before restoring","Never delete the temp restore-map directory mid-restore","Use the exact --backup_id corresponding to the desired restore point"],"tags":["dgraph","restore","badger","stream-writer","reducer"],"backgroundTag":"backup-restore-failed","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}