{"record":{"id":"7844aea35e76f46f","repo":"dgraph-io/dgraph","slug":"while-dumping-table-s","errorCode":null,"errorMessage":"while dumping table %s","messagePattern":"while dumping table (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dgraph/cmd/migrate/dump.go","lineNumber":74,"sourceCode":"\t\ttableInfo := m.tableInfos[table]\n\t\tfor _, index := range createDgraphSchema(tableInfo) {\n\t\t\t_, err := m.schemaWriter.WriteString(index)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrapf(err, \"while writing schema\")\n\t\t\t}\n\t\t}\n\t}\n\treturn m.schemaWriter.Flush()\n}\n\n// dumpTables goes through all the tables twice. In the first time it generates RDF entries for the\n// column values. In the second time, it follows the foreign key constraints in SQL tables, and\n// generate the corresponding Dgraph edges.\nfunc (m *dumpMeta) dumpTables() error {\n\tfor table := range m.tableInfos {\n\t\tfmt.Printf(\"Dumping table %s\\n\", table)\n\t\tif err := m.dumpTable(table); err != nil {\n\t\t\treturn errors.Wrapf(err, \"while dumping table %s\", table)\n\t\t}\n\t}\n\n\tfor table := range m.tableInfos {\n\t\tfmt.Printf(\"Dumping table constraints %s\\n\", table)\n\t\tif err := m.dumpTableConstraints(table); err != nil {\n\t\t\treturn errors.Wrapf(err, \"while dumping table %s\", table)\n\t\t}\n\t}\n\n\treturn m.dataWriter.Flush()\n}\n\n// dumpTable converts the cells in a SQL table into RDF entries,\n// and sends entries to the m.dataWriter\nfunc (m *dumpMeta) dumpTable(table string) error {\n\ttableGuide := m.tableGuides[table]\n\ttableInfo := m.tableInfos[table]","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/dgraph/cmd/migrate/dump.go#L56-L92","documentation":"dumpTables first phase calls dumpTable for every table in m.tableInfos, which reads all SQL rows and emits RDF data to the data writer. If any per-table dump fails (SQL query error, scan error, getValue error), it is wrapped with \"while dumping table <name>\" so the offending table is identified.","triggerScenarios":"m.dumpTable(table) returns an error for any table: the SELECT of the table fails, rows.Next() hits an unexpected driver error, or a row cell fails conversion in getValue (nil value, invalid NullInt64/NullTime/NullFloat64).","commonSituations":"MySQL connection dropped mid-migration; a table contains NULLs the converter rejects; unsupported column type causes type assertion panic/error downstream; insufficient privileges to read a table.","solutions":["Identify the table name embedded in the wrapped message and run a manual SELECT on it to find the bad rows.","Fix NULL/invalid values in that table (or preprocess with COALESCE) before migrating.","Verify DB connectivity and grants for the migrate user on that table.","Rerun migrate; since it is a full dump, restart after fixing the data source."],"exampleFix":"// before\nSELECT * FROM orders; -- row with NULL cust_id crashes dumpTable\n// after\nSELECT id, COALESCE(cust_id, 0) AS cust_id, ... FROM orders; -- or clean NULLs before migrating","handlingStrategy":"validation","validationCode":"-- find problematic rows before migrating\nSELECT COUNT(*) FROM orders WHERE cust_id IS NULL OR id IS NULL;","typeGuard":null,"tryCatchPattern":"if err := migrate.Run(); err != nil {\n\tvar tbl string\n\tif m := tableRe.FindStringSubmatch(err.Error()); m != nil {\n\t\ttbl = m[1] // parse table from \"while dumping table X\"\n\t}\n\tlog.Printf(\"dump failed for table %s: %+v\", tbl, err)\n}","preventionTips":["Audit tables for NULLs and unsupported column types before migrating","Verify DB connectivity and read grants for all in-scope tables","Run migrations on a stable connection with adequate timeouts"],"tags":["migration","sql","data-conversion"],"backgroundTag":"sql-dump-table-failed","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}