Problems with migrating data with foreign key constraints.
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 20/100
Direzione di ricerca
Start with the issue's MySQL example of ON DELETE CASCADE and ON UPDATE CASCADE while FOREIGN_KEY_CHECKS is disabled. Trace how ghostferry applies parent-row updates and deletes to the target, then define a reproducible consistency check for the affected child tables; the issue does not name specific files or tests.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The main reason behind migrating tables with foreign key constraints is that they can have referential actions for a foreign key such as ON DELETE CASCADE, ON UPDATE CASCADE.
Cascading deletes and updates in child tablees caused by foreign key constraints don't show up in binlogs because these referential actions are dealt internally by InnoDB. Check out this link - https://dba.stackexchange.com/questions/51873/replication-binary-log-parsingtableid-generation-on-delete-cascade-handling.
Let's take a look at this sql example on a source database :-
mysql> SET FOREIGN_KEY_CHECKS=0;
Query OK, 0 rows affected (0.00 sec)
mysql> use gf_test;
Database changed
mysql> CREATE TABLE IF NOT EXISTS t1 (id1 bigint(20), primary key(id1));
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> CREATE TABLE IF NOT EXISTS t2 (id2 bigint(20), primary key(id2), CONSTRAINT fkc2 foreign key(id2) REFERENCES t1(id1) ON DELETE CASCADE ON UPDATE CASCADE);
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> INSERT INTO t1 VALUES (1);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO t2 VALUES (1);
Query OK, 1 row affected (0.01 sec)
mysql> UPDATE t1 SET id1 = 2 WHERE id1 = 1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> SELECT * FROM t1;
+-----+
| id1 |
+-----+
| 2 |
+-----+
1 row in set (0.00 sec)
mysql> SELECT * FROM t2;
+-----+
| id2 |
+-----+
| 1 |
+-----+
1 row in set (0.00 sec)
We can clearly see here that since foreign key checks are disabled on the database updating the parent table does not change the foreign keys in child tables.
In terms of ghostferry migration when the rows are updated or deleted from the parent table in source database cascade won't update,delete rows in the child table if they're already present in the target database, eventually leading the database in an inconsistent state.
- Lingua principale
- Go
- Stelle
- 858
- Fork
- 77
- Merge medio
- 10g 4h
- PR unite (30g)
- 4
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Shopify/ghostferry
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
Shopify/ghostferry#471 · 1 commento ·
-
Trouble with virtual generated columnsForse già presa @driv3r l’ha presa 222 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
Shopify/ghostferry#338 · 7 commenti ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
Shopify/ghostferry#332 · 1 commento ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
Shopify/ghostferry#318 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
Shopify/ghostferry#306 ·
Tutte le issue di Shopify/ghostferry
Issue simili
-
[Bug]: gate 缺失Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
I maintainer di solito rispondono entro 1 giorno
-
Generated cask uses deprecated `postflight` stanza; Homebrew 7 warns on every commandForse già presa @k4kratik l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
sachincool/cruft#4 ·
-
help wanted kind/good-first-issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
knative/func#4191 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
VictoriaMetrics/VictoriaLogs#1965 ·
I maintainer di solito rispondono entro 1 giorno
-
kind/bug sig/ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
kubermatic/dashboard#8540 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno