{"record":{"id":"c1c71301ee689a58","repo":"dgraph-io/dgraph","slug":"cannot-export-data-inside-db-at-s","errorCode":null,"errorMessage":"cannot export data inside DB at %s","messagePattern":"cannot export data inside DB at (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"worker/backup.go","lineNumber":167,"sourceCode":"}\n\nfunc StoreExport(request *pb.ExportRequest, dir string, key x.Sensitive) error {\n\tdb, err := badger.OpenManaged(badger.DefaultOptions(dir).\n\t\tWithSyncWrites(false).\n\t\tWithValueThreshold(1 << 10).\n\t\tWithNumVersionsToKeep(math.MaxInt32).\n\t\tWithEncryptionKey(key))\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() {\n\t\tif err := db.Close(); err != nil {\n\t\t\tglog.Warningf(\"error closing the DB: %v\", err)\n\t\t}\n\t}()\n\n\t_, err = exportInternal(context.Background(), request, db, true)\n\treturn errors.Wrapf(err, \"cannot export data inside DB at %s\", dir)\n}\n\n// Backup handles a request coming from another node.\nfunc (w *grpcWorker) Backup(ctx context.Context, req *pb.BackupRequest) (*pb.BackupResponse, error) {\n\tglog.V(2).Infof(\"Received backup request via Grpc: %+v\", req)\n\treturn backupCurrentGroup(ctx, req)\n}\n\nfunc backupCurrentGroup(ctx context.Context, req *pb.BackupRequest) (*pb.BackupResponse, error) {\n\tglog.Infof(\"Backup request: group %d at %d\", req.GroupId, req.ReadTs)\n\tif err := ctx.Err(); err != nil {\n\t\tglog.Errorf(\"Context error during backup: %v\\n\", err)\n\t\treturn nil, err\n\t}\n\n\tg := groups()\n\tif g.groupId() != req.GroupId {\n\t\treturn nil, errors.Errorf(\"Backup request group mismatch. Mine: %d. Requested: %d\\n\",","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/worker/backup.go#L149-L185","documentation":"StoreExport opens a Badger DB over the export directory and runs exportInternal to stream data out. When the internal export fails for any reason (I/O error, corrupt manifest, encryption issues, badger errors), the failure is wrapped with the directory path so the developer knows which DB location could not be exported.","triggerScenarios":"Calling StoreExport(request, dir, key) where badger.OpenManaged succeeded but exportInternal returned a non-nil error, e.g. reading a tablet/DB at `dir` fails mid-stream or the export pipeline hits an I/O or decode error.","commonSituations":"Exporting from a partially written or corrupted export directory; disk full or permission problems on the export dir; encryption key mismatch between what was used to write the DB and the `key` passed to StoreExport; interrupted prior export leaving the DB in a bad state.","solutions":["Check the wrapped (inner) error in the message for the root cause from exportInternal and fix that underlying issue first","Verify the directory `dir` exists, is readable, and has free disk space","Ensure the same x.Sensitive encryption key used when the DB was written is passed to StoreExport","Re-run the export; if the dir is corrupt, regenerate it from a fresh backup/export"],"exampleFix":"// before\n_, err = exportInternal(context.Background(), request, db, true)\nreturn errors.Wrapf(err, \"cannot export data inside DB at %s\", dir)\n// after\n_, err = exportInternal(context.Background(), request, db, true)\nif err != nil {\n    glog.Errorf(\"export from %s failed: %v\", dir, err) // log root cause before wrapping\n}\nreturn errors.Wrapf(err, \"cannot export data inside DB at %s\", dir)","handlingStrategy":"try-catch","validationCode":"if info, err := os.Stat(dir); err != nil || !info.IsDir() {\n    return fmt.Errorf(\"export dir %s missing or not a directory\", dir)\n}","typeGuard":null,"tryCatchPattern":"if _, err := StoreExport(req, dir, key); err != nil {\n    var root error = errors.Cause(err)\n    glog.Errorf(\"export at %s failed: %v\", dir, root)\n    return root\n}","preventionTips":["Verify the export directory exists and is writable before calling StoreExport","Pass the exact encryption key used to write the DB","Monitor disk free space on the export volume","Keep export requests within timeouts so partial exports don't pile up"],"tags":["badger","export","io","storage"],"backgroundTag":"export-operation-failed","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}