createCollection: make the metadata row the atomic claim so concurrent creators cannot drop each other's schema

Đang mở
#939 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
php
Lĩnh vực
databases

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

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của utopia-php/database

Tất cả issue của utopia-php/database

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.