Skip to content

Add option to fail the gh-ost process on SQL warnings #1498

Open
@grodowski

Description

@grodowski

My team is investigating using Gh-ost for online schema migrations and we'd like to propose a feature we've been relying on in our current approach with LHM.

A new CLI option (raise_on_warnings?) would query for SHOW WARNINGS after each insert batch and fail the migration if warnings are found. This would optionally prevent data loss when e.g.:

  • adding a unique index with duplicate rows
  • changing table's collation causing new duplicates
  • adding a not null constraint with null values
  • resizing columns

An equivalent in LHM is raise_on_warnings: https://github.com/Shopify/lhm/blob/46204927a2933cfe239c77ac84ab58b5c7deb3a0/lib/lhm/chunker.rb#L92-L100

I have a prototype that shows the direction of how this option could be implemented in Applier.ApplyIterationInsertQuery: Shopify#1

Some open questions:

  • Is it desired to always process warnings (with the CLI option enabled) or only if a row count discrepancy has been detected. The latter is the current, less strict behaviour of Shopify/lhm

I'd love to hear your suggestions before we propose a PR contribution, thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions