You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PanicOnWarnings option to detect SQL warnings and fail the copy process (#1500)
* First pass at raise_on_warnings
* Update dev.yml
* add CLI option, ignore expected warnings, check for row count discrepancy
* Count rows in each insert range prepared query
- log insert warnings always
- terminate if row count doesn't match and the PanicOnWarnings flag is set
* Lint comments - ensure errors are handled in show warnings
* update TestBuildUniqueKeyRangeEndPreparedQuery
* Localtests for PanicOnWarnings with data loss
* Unwrap CTE (mysql 5)
* Update localtests/panic-on-warnings-duplicate-unique-values-on-column-type-change/extra_args
Co-authored-by: Bastian Bartmann <accounts@bastianbartmann.de>
* limit BuildUniqueKeyRangeEndPreparedQueryViaOffset subquery properly
* Update Applier to support all unique indices with PanicOnWarnings. Add test coverage.
* Impl code review feedback for PanicOnWarnings
- documentation
- remove dev.yml
- remove unused variable
* bump golangci-lint for local dev
* Support altering index names with PanicOnWarnings
* Fix string matching for PanicOnWarnings to correctly suppress warnings when renaming unique keys
Error message formats are different across mysql distributions and versions
---------
Co-authored-by: Bastian Bartmann <accounts@bastianbartmann.de>
Copy file name to clipboardExpand all lines: doc/command-line-flags.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -202,6 +202,12 @@ List of metrics and threshold values; topping the threshold of any will cause th
202
202
203
203
Typically `gh-ost` is used to migrate tables on a master. If you wish to only perform the migration in full on a replica, connect `gh-ost` to said replica and pass `--migrate-on-replica`. `gh-ost` will briefly connect to the master but otherwise will make no changes on the master. Migration will be fully executed on the replica, while making sure to maintain a small replication lag.
204
204
205
+
### panic-on-warnings
206
+
207
+
When this flag is set, `gh-ost` will panic when SQL warnings indicating data loss are encountered when copying data. This flag helps prevent data loss scenarios with migrations touching unique keys, column collation and types, as well as `NOT NULL` constraints, where `MySQL` will silently drop inserted rows that no longer satisfy the updated constraint (also dependent on the configured `sql_mode`).
208
+
209
+
While `panic-on-warnings` is currently disabled by defaults, it will default to `true` in a future version of `gh-ost`.
210
+
205
211
### postpone-cut-over-flag-file
206
212
207
213
Indicate a file name, such that the final [cut-over](cut-over.md) step does not take place as long as the file exists.
Copy file name to clipboardExpand all lines: go/cmd/gh-ost/main.go
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -108,6 +108,7 @@ func main() {
108
108
chunkSize:=flag.Int64("chunk-size", 1000, "amount of rows to handle in each iteration (allowed range: 10-100,000)")
109
109
dmlBatchSize:=flag.Int64("dml-batch-size", 10, "batch size for DML events to apply in a single transaction (range 1-100)")
110
110
defaultRetries:=flag.Int64("default-retries", 60, "Default number of retries for various operations before panicking")
111
+
flag.BoolVar(&migrationContext.PanicOnWarnings, "panic-on-warnings", false, "Panic when SQL warnings are encountered when copying a batch indicating data loss")
111
112
cutOverLockTimeoutSeconds:=flag.Int64("cut-over-lock-timeout-seconds", 3, "Max number of seconds to hold locks on tables while attempting to cut-over (retry attempted when lock exceeds timeout) or attempting instant DDL")
112
113
niceRatio:=flag.Float64("nice-ratio", 0, "force being 'nice', imply sleep time per chunk time; range: [0.0..100.0]. Example values: 0 is aggressive. 1: for every 1ms spent copying rows, sleep additional 1ms (effectively doubling runtime); 0.7: for every 10ms spend in a rowcopy chunk, spend 7ms sleeping immediately after")
0 commit comments