[Bug][Migration] modify refs id length fails on MySQL Group Replication and leaves refs without a primary key
Maintainer thường phản hồi trong vòng 3 ngày
@tpam28 đang làm issue này rồi.
Từ ngày 7/10/2026.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
Hướng nghiên cứu
Start with migration 20240124155129 and trace its call to migrationhelper.ChangePrimaryKeyColumnsType; the issue identifies this helper as used only by this migration. Check the migration’s behavior on MySQL with Group Replication, where DML on a table without a primary key fails. Done means the migration succeeds and refs retains its primary key throughout.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Search before asking
- I had searched in the issues and found no similar issues.
What happened
On a fresh database, migration 20240124155129 ("modify refs id length from 255 to 500") fails on MySQL with Group Replication. DevLake doesn't start.
The migration calls migrationhelper.ChangePrimaryKeyColumnsType. On MySQL that function:
- runs
ALTER TABLE refs DROP PRIMARY KEY; - renames
idto a temp column, adds a newidcolumn, and copies data withUPDATE refs SET id = <tmp> ...; - runs
ALTER TABLE refs ADD PRIMARY KEY (id).
Group Replication requires every replicated table to have a primary key or an equivalent non-null unique key (https://dev.mysql.com/doc/refman/8.0/en/group-replication-requirements.html). It rejects DML on tables without one, so step 2 fails even on an empty table:
[migrator] applying migration script modify refs id length from 255 to 500:20240124155129
dalgorm.go:286 Error 3098 (HY000): The table does not comply with the requirements by an external plugin.
[rows:0] UPDATE `refs` SET `id`= `id_5F25450158E7FFB26E242E4DA0AE9F41` ,`updated_at`='...' WHERE `id_5F25450158E7FFB26E242E4DA0AE9F41` IS NOT NULL
panic: Error 3098 (HY000): The table does not comply with the requirements by an external plugin. (500)
Step 3 never runs. The rollback in ChangeColumnsType restores the id column but not the primary key, so refs stays without one. The next start fails on the same migration, now at step 1:
panic: Error 1091 (42000): Can't DROP 'PRIMARY'; check that column/key exists (500)
What do you expect to happen
The migration succeeds on MySQL with Group Replication, and refs keeps its primary key the whole time. Group Replication is what MySQL InnoDB Cluster runs on, so DevLake can't use an HA MySQL setup while this migration drops the key before copying data.
How to reproduce
-
Start a single-node MySQL 8.0 with Group Replication:
cat > gr.cnf <<'EOF' [mysqld] server_id=1 gtid_mode=ON enforce_gtid_consistency=ON plugin_load_add=group_replication.so loose-group_replication_group_name=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee loose-group_replication_start_on_boot=OFF loose-group_replication_local_address=127.0.0.1:33061 loose-group_replication_group_seeds=127.0.0.1:33061 EOF docker run -d --name devlake-gr -p 3307:3306 \ -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=lake \ -e MYSQL_USER=merico -e MYSQL_PASSWORD=merico \ -v "$PWD/gr.cnf:/etc/mysql/conf.d/gr.cnf:ro" mysql:8.0 docker exec devlake-gr mysql -uroot -proot -e "SET GLOBAL group_replication_bootstrap_group=ON; START GROUP_REPLICATION; SET GLOBAL group_replication_bootstrap_group=OFF;" -
Start DevLake with
DB_URL=mysql://merico:[email protected]:3307/lake?charset=utf8mb4&parseTime=True&loc=UTCandFORCE_MIGRATION=true. -
DevLake panics on migration
20240124155129with error 3098. -
SHOW CREATE TABLE refsshows no primary key. Starting DevLake again panics with error 1091.
Anything else
It happens every time on a fresh database. On plain MySQL without Group Replication the migration passes.
Related: #6451 (Group Replication, missing primary keys on other tables; closed as stale), #6292 (same drop-then-re-add pattern failing on Azure MySQL with GIPK). Neither covers the refs migration.
Widening a varchar primary key doesn't need the drop/copy/re-add sequence. On MySQL, ALTER TABLE refs MODIFY id varchar(500) keeps the key and the data. ChangePrimaryKeyColumnsType is only used by this migration.
Version
02dab0cda304298a2a47737ada4a616921b7c914 (current main); also seen on b3f18854ad58b5cf0e9a56c14266af17ae19894f
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
- Ngôn ngữ chính
- Go
- Star
- 3.2k
- Fork
- 819
- Merge trung bình
- 3 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 37
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- 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 apache/devlake
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 55/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
apache/devlake#9195 · 1 reaction ·
Maintainer thường phản hồi trong vòng 3 ngày
-
[Bug][jenkins] Incremental collection skips the stages of builds that finish after the next syncCó thể đã có người làm @pballester đã nhận 13 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
apache/devlake#9177 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
[Bug][Jira/DORA] Extra JQL does not isolate projects sharing the same Jira boardCó thể đã có người làm @veetmoradiya3628 đã nhận 20 ngày trước. Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
apache/devlake#9151 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
-
type/bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
apache/devlake#9150 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của apache/devlake
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
prime-radiant-inc/evener#4329 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add `pdfcpu` to the pantryĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
openwatersio/aiscast#277 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
restic/restic#22112 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày