-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PanicOnWarnings option to detect SQL warnings and fail the copy process #1500
base: master
Are you sure you want to change the base?
Conversation
- log insert warnings always - terminate if row count doesn't match and the PanicOnWarnings flag is set
…-type-change/extra_args Co-authored-by: Bastian Bartmann <[email protected]>
Ran gh-ost locally on a Migrate cmd:
Generic
Then, ran these explains on the copy query (
Looks like there will be no significant change in perf? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new CLI flag (panic-on-warnings) that causes gh-ost to fail when SQL warnings are detected during row copying and also logs all SQL warnings.
- A new flag "--panic-on-warnings" is added in the main CLI and corresponding context fields.
- The iteration range calculation now also returns an expected row count with adjusted logic to process SQL warnings.
- Various SQL builder functions and tests have been updated to support the enhanced query structure and error handling.
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
dev.yml | Adds configuration for testing environments and dependency management. |
go/logic/applier.go | Updates range end calculation and SQL warning processing logic. |
go/sql/builder_test.go | Adjusts expected queries and argument lists in tests to match new behavior. |
go/logic/migrator.go | Incorporates expected range size into chunk iteration and warning checks. |
go/sql/builder.go | Modifies SQL builder queries with minor refactorings and marks an unused variable. |
go/cmd/gh-ost/main.go | Introduces the new CLI flag for panic-on-warnings. |
go/base/context.go | Adds new context fields for managing SQL warnings and panic configuration. |
Comments suppressed due to low confidence (1)
go/sql/builder.go:278
- [nitpick] The variable 'uniqueKeyColumnDescending' is declared but not used anywhere in the function. Removing it could improve code clarity.
uniqueKeyColumnDescending := make([]string, len(uniqueKeyColumnNames)) // TODO unused variable
for _, warning := range this.migrationContext.MigrationLastInsertSQLWarnings { | ||
this.migrationContext.Log.Infof("ApplyIterationInsertQuery has SQL warnings! %s", warning) | ||
} | ||
if expectedRangeSize != rowsAffected { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error generated by terminateRowIteration is not being returned, which may inadvertently allow execution to continue even after detecting SQL warnings. Consider returning the error from terminateRowIteration to abort the operation as intended.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
Looks good! I will test the performance of this internally (hopefully this week) |
Related issue: #1498
Description
This PR adds a CLI flag
--panic-on-warnings
that makesgh-ost
fail after copying each batch when:affectedRows
)I also decided to always log all SQL warnings, which could be useful to find issues with data truncation or not null constraints even when the row count matches.
Opening as draft with a few remaining items:
check explain analyze on the updated range select queryscript/cibuild
returns with no formatting errors, build errors or unit test errors.