github / github/gh-ost

gh-ost is not properly identifying column types

Offen
#660 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Go
Sterne
13.6k
Forks
1.4k
Ø Merge
2 Std. 31 Min.
Gemergte PRs (30 T.)
4

Beschreibung

I'm facing an issue when trying to alter a table that contains a `json` column.

Original table
```sql
CREATE TABLE `xxx_shipping` (
`xxx_id` bigint(20) unsigned NOT NULL,
`zones` json NOT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`xxx_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
```

Final table
```sql
CREATE TABLE `_xxx_shipping_gho` (
`xxx_id` bigint(20) unsigned NOT NULL,
`my_new_column` json DEFAULT NULL,
`zones` json NOT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`xxx_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
```

At some point during the migration I get the following error message:

```
2018-10-31 14:59:57 ERROR Error 3144: Cannot create a JSON value from a str
ing with CHARACTER SET 'binary'.; query=
replace /* gh-ost `my_database`.`_xxx_shipping_gho` */ in
to
`my_database`.`_xxx_shipping_gho`
(`xxx_id`, `zones`, `updated_at`)
values
(?, ?, ?)
; args=[15680576 [123 34 97 100 34 58 91 93 44 34 97 101 34 58 91 93 44 3
4 97 102 34 58 91 93 44 34 97 103 34 58 91 93 44 34 97 105 34 58 91 93 44 3
4 97 108 34 58 91 93 44 34 97 109 34 58 91 93 44 34 97 111 34 58 91 93 44 3
4 97 113 34 58 91 93 44 34 97 114 34 58 91 93 44 34 97 115 34 58 91 93 44 3
4 97 116 34 58 91 93 44 34 97 117 34 58 91 93 44 34 97 119 34 58 91 93 44 3
...
```

The `gh-ost` `--alert` parameter is:
```
--alter="add my_new_column json null after xxx_id"
```

Part of the data is properly migrated, usually the migration fails after the first batch. I created a PR already that solves the problem. I will link this issue in the PR.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Reproduziere die gemeldete gh-ost-Migration anhand der bereitgestellten MySQL-Tabellendefinitionen und der JSON-Spalte und überprüfe anschließend den in der Issue erwähnten bestehenden PR. Die Aufgabe ist erledigt, wenn die Migration erfolgreich abgeschlossen wird und JSON-Werte nicht abgelehnt werden, weil sie den binären Zeichensatz verwenden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
go, mysql
Bereich
databases
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.