Race-condition in beforeCurrent hook
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- postgresql, typescript
Hướng nghiên cứu
Bắt đầu bằng cách lần theo hook beforeCurrent và cách watch xử lý nhiều lần lưu tệp gần như đồng thời; issue không cung cấp tệp nguồn hoặc vị trí kiểm thử. Tái hiện bằng hook pg_dump-beforeCurrent và restoreCurrentData.sql trong afterCurrent khi thay đổi nhiều tệp cùng lúc. Hoàn tất khi việc thực thi hook được tuần tự hóa và dump luôn chứa dữ liệu trước khi các migration được chạy lại.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
I use pg_dump to save data from tables, that are currently under development, and sometimes, pg_dump yields no data, sometimes it does, although there was data, before the current migrations were re-deployed.
Steps to reproduce
My hook in beforeCurrent:
(I use -T committed_table to only export data from tables, that will be destroyed and recreated.)
{
"_": "command",
"command": "pg_dump \"$GM_DBURL\" --data-only --schema app_public -T app_public.users -T app_public.user_emails -T app_public.user_authentications -T app_public.organizations -T app_public.organization_memberships -T app_public.organization_invitations --column-inserts --no-comments --rows-per-insert=1000 --file migrations/restoreCurrentData.sql"
}
The corresponding hook in afterCurrent
{
"_": "sql",
"file": "restoreCurrentData.sql",
"shadow": false
}
Expected results
restoreCurrentData.sql should always contain the data that was present, before the current migrations were about to re-run.
Actual results
restoreCurrentData.sql is sometimes empty, most often, when I changed multiple files at once. (Even if using save all in VSCode.) It happens less frequent, if I change my files one after another.
Additional context
Our conversation on Discord:
timostolz - at 2023-06-21 08:38:00+00:00
If I have "beforeCurrent" hooks in graphile-migrate, will they run synchronously, and will their end state be awaited, before the current migrations are deployed?
timostolz
I use pg_dump to save data from tables, that are currently under development, and sometimes, pg_dump yields no data, sometimes it does, although there was data, before the current migrations were re-deployed. However, if the current migrations and pg_dump run at the same time, a race-condition could explain this problem. Under this assumption, the tables could be dropped before pg_dump begins to export the data, finally leading to an empty result.
Benjie
Please file an issue and I’ll look into it. They should but I wonder if watch can trigger twice concurrently
timostolz
Ahh, up to now, I thought it happens completely at random. But as you come up with triggering twice: Most often, it happens, if I change two or more files at once. (Although I use the "Save all" command in VSCode to save them nearly at the same time.)
Benjie
Yeah it makes sense I’d forget to add a queue there especially given the SQL will queue automatically due to transactions, so without a beforeCurrent I wouldn’t notice the issue
Also hard to reproduce because everything is so fast, unless you’re using something like save all
- Ngôn ngữ chính
- TypeScript
- Star
- 836
- Fork
- 71
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọ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 graphile/migrate
-
Partition migrations folderĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
-
🐛 bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
Tất cả issue của graphile/migrate
Issue tương tự
-
foreground-up-signals-live: delivery-repair cell expects a spawn suggestion status no longer printsĐang mởbug triage:owned
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
e2e-failure ready-to-code
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
redhat-developer/rhdh-plugin-export-overlays#4905 · 1 bình luận ·
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
directus/directus#28558 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
review: medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
1lck/Lithe-IDEA#2432 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
cloudflare/workers-sdk#17189 ·
Maintainer thường phản hồi trong vòng 1 ngày