Skip to content

dump nullable BIGINT UNSIGNED values above 2^63-1 and fail on row errors - #558

Open
jayhemnani9910 wants to merge 1 commit into
databacker:mainfrom
jayhemnani9910:fix/dump-unsigned-bigint
Open

jayhemnani9910 wants to merge 1 commit into
databacker:mainfrom
jayhemnani9910:fix/dump-unsigned-bigint

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

A nullable BIGINT UNSIGNED column with a value above 2^63-1 breaks the dump:

CREATE TABLE t (id INT PRIMARY KEY, h BIGINT UNSIGNED);
INSERT INTO t VALUES (1,5),(2,9223372036854775808),(3,NULL),(4,18446744073709551615),(5,7);

mysql-backup dump --include b ... fails with failed to dump database b: busy buffer. With --routines=false it logs "Backup complete" and exits 0, but the dump holds only VALUES (1,5).

go-sql-driver reports a nullable BIGINT UNSIGNED as sql.NullInt64, so rows.Scan fails on values above 2^63-1. Next() keeps that error on the table and returns false, but nothing reads it: the INSERT ends at that row, and the next query on the connection hits the unread result set ("busy buffer").

  • reflectColumnType scans UNSIGNED BIGINT into sql.Null[uint64], and RowBuffer writes it as a number or NULL.
  • Next() closes the rows on a scan error and keeps rows.Err() when the rows end, and Execute returns the table's error, so a failed table fails the dump instead of leaving it short. The same gap hit any error while reading rows: with max_execution_time=300 on a 1.5M-row table, main logs "Backup complete" with 431,842 rows; now the dump fails with Error 3024 ... Query execution was interrupted. This matches mysqldump without --force.

Tested against mysql:8.4: the dump now has all five rows, a restore into a new database gives the same CHECKSUM TABLE. With only the second change, the same table fails with the scan error (exit 1) instead of a short "complete" backup. New TestRowBufferUnsignedBigint fails without the change; go test ./pkg/... ./cmd/... passes. The integration suite in test/ was not run here.

The driver reports a nullable BIGINT UNSIGNED column as NullInt64, so a
value above 2^63-1 failed to scan. The scan error was kept on the table
but never returned: the table's INSERT just ended at that row, and the
next query failed with "busy buffer" (or, with nothing after it, the
dump reported success). An error while reading rows (a query timeout or
a lost connection) was not read at all, with the same result.

Scan these columns into sql.Null[uint64], keep rows.Err() when the rows
end, and return the table's error from Execute so a failed table fails
the dump instead of leaving it short.

Signed-off-by: Jay Hemnani <193022578+jayhemnani9910@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant