createCollection: make the metadata row the atomic claim so concurrent creators cannot drop each other's schema
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
- 35/100
Hướng nghiên cứu
Start at createCollection() and read the existing rollback and orphan-recovery paths, using testCreateCollectionConcurrentlyKeepsPeerData as the current concurrency test. Add a seam that pauses a creator between schema and metadata operations, then cover the metadata-first claim and competing creators deterministically. Done means the loser cannot drop the winner's schema, and failed physical creation rolls back its metadata row.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Follow-up to #938, which fixed the two reachable orderings but deliberately left this one open.
The residual window
createCollection() creates the physical table first and inserts the metadata row second, so between those two steps a collection exists that nothing in metadata describes. A second creator that reads metadata inside that window sees nothing, takes the adapter's Duplicate as proof of an orphan, and drops the first creator's table. The first creator's metadata insert then commits, pointing at a collection that is no longer there.
#938 re-reads metadata past the cache before concluding a table is an orphan, which removes the orderings that a rolling restart actually hit, and stops the loser from rolling back a table the winner owns. It does not make the sequence atomic — nothing serialises the two creators.
Proposed fix
Insert the metadata row first, then create the physical table. The unique key on _uid becomes the claim: exactly one creator wins it, and the loser gets Duplicate before it can touch any schema. On a physical-create failure the winner rolls back its own metadata row.
This is a design change, not a patch:
- it inverts the ordering of a hot path
- the transient orphan state becomes "metadata without a table" instead of "table without metadata", so orphan recovery has to be rewritten around the new shape
- every existing rollback path changes what it is rolling back
Testing
Needs a seam the code does not currently have: a way to pause one creator after its schema write and before its metadata write, so a second creator can be driven through the window deterministically. #938's testCreateCollectionConcurrentlyKeepsPeerData covers the cache-driven orderings but cannot reach this one.
The absence of that seam is itself part of the work.
- Ngôn ngữ chính
- PHP
- Star
- 74
- Fork
- 59
- Merge trung bình
- 10 giờ 45 phút
- Pull request đã merge (30 ngày)
- 20
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 utopia-php/database
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
utopia-php/database#923 · 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
utopia-php/database#328 · 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
utopia-php/database#94 · 1 bình luận ·
Tất cả issue của utopia-php/database
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
getgrav/grav-plugin-api#45 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
RSS-Bridge/rss-bridge#5098 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
phingofficial/phing#2025 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
silverstripe/developer-docs#911 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100