Problems with migrating data with foreign key constraints.
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 20/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Go
- Star
- 858
- Fork
- 77
- Merge trung bình
- 10 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Shopify/ghostferry
-
Gradual copy throttle recoveryĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
Shopify/ghostferry#471 · 1 bình luận ·
-
Trouble with virtual generated columnsCó thể đã có người làm @driv3r đã nhận 222 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
Shopify/ghostferry#338 · 7 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
Shopify/ghostferry#332 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Shopify/ghostferry#318 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Shopify/ghostferry#306 ·
Tất cả issue của Shopify/ghostferry
Issue tương tự
-
[Bug]: gate 缺失Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Generated cask uses deprecated `postflight` stanza; Homebrew 7 warns on every commandCó thể đã có người làm @k4kratik đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
sachincool/cruft#4 ·
-
help wanted kind/good-first-issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
knative/func#4191 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
VictoriaMetrics/VictoriaLogs#1965 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
kind/bug sig/ui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
kubermatic/dashboard#8540 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày