github / github/gh-ost

gh-ost is not properly identifying column types

Aperta
#660 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Go
Stelle
13.6k
Fork
1.4k
Merge medio
2h 31m
PR unite (30g)
4

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Riproduci la migrazione gh-ost segnalata utilizzando le definizioni delle tabelle MySQL e la colonna JSON fornite, quindi esamina il PR esistente menzionato nell’issue. L’attività è completata quando la migrazione termina correttamente e i valori JSON non vengono rifiutati perché usano il set di caratteri binario.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
go, mysql
Ambito
databases
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.