Repository navigation
dump nullable BIGINT UNSIGNED values above 2^63-1 and fail on row errors - #558
Open
jayhemnani9910 wants to merge 1 commit into
Open
jayhemnani9910 wants to merge 1 commit into
jayhemnani9910 wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A nullable
BIGINT UNSIGNEDcolumn with a value above 2^63-1 breaks the dump:mysql-backup dump --include b ...fails withfailed to dump database b: busy buffer. With--routines=falseit logs "Backup complete" and exits 0, but the dump holds onlyVALUES (1,5).go-sql-driver reports a nullable BIGINT UNSIGNED as
sql.NullInt64, sorows.Scanfails 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").reflectColumnTypescansUNSIGNED BIGINTintosql.Null[uint64], andRowBufferwrites it as a number or NULL.Next()closes the rows on a scan error and keepsrows.Err()when the rows end, andExecutereturns 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: withmax_execution_time=300on a 1.5M-row table, main logs "Backup complete" with 431,842 rows; now the dump fails withError 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. NewTestRowBufferUnsignedBigintfails without the change;go test ./pkg/... ./cmd/...passes. The integration suite intest/was not run here.