Upcoming papers sync can run twice at once and duplicate or empty the list
Maintainer thường phản hồi trong vòng 4 ngà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
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- mongodb, typescript
Hướng nghiên cứu
Read src/lib/services/upcoming-sync.ts, especially the date check and the deleteMany/insertMany sequence. The issue suggests claiming the day atomically and replacing subjects transactionally or with a bulk write; first check the open pull request #563 to understand work already underway. Done means concurrent requests cannot duplicate subjects or serve an empty list during the sync.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
checkAndSyncUpcomingSlots runs on the first /api/upcoming-papers request after the daily cutoff, it reads lastSyncedDate rebuilds the list and then does deleteMany({}) followed by insertMany(...), redudant
https://github.com/CodeChefVIT/papers-codechef/blob/6e3aa1152a34c7eb46d36f58294dffd9ff3b3c7b/src/lib/services/upcoming-sync.ts#L31
https://github.com/CodeChefVIT/papers-codechef/blob/6e3aa1152a34c7eb46d36f58294dffd9ff3b3c7b/src/lib/services/upcoming-sync.ts#L89-L103
Nothing stops two requests that arrive together from both seeing the old date and both running the sync, then:
- both delete and both insert, so every upcoming subject can appear twice or
- a request served between one syncs delete and its insert sees an empty list and gets a 404
To Reproduce
hard to hit by hand, Send several requests to /api/upcoming-papers at the same moment just after the cutoff on a day that hasnt synced yet, then check the upcomingsubjects collection for duplicates
Expected behavior
Only one request should run the sync. eg: claim the day atomically first with findOneAndUpdate({ lastSyncedDate: { $ne: today } }, { $set: { lastSyncedDate: today } }) and only sync if that update matched then replace the subjects in a transaction or with a bulk write
- Ngôn ngữ chính
- TypeScript
- Star
- 23
- Fork
- 67
- Merge trung bình
- 2 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 7
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- 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 CodeChefVIT/papers-codechef
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
CodeChefVIT/papers-codechef#577 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
CodeChefVIT/papers-codechef#552 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 4 ngày
-
/api/upcoming-papers Throws 404 When No Exams are ActiveCó thể đã có người làm @Dx-Alz-xD đã nhận 16 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
CodeChefVIT/papers-codechef#549 · 1 reaction ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 69/100
CodeChefVIT/papers-codechef#576 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 64/100
CodeChefVIT/papers-codechef#575 ·
Maintainer thường phản hồi trong vòng 4 ngày
Tất cả issue của CodeChefVIT/papers-codechef
Issue tương tự
-
enhancement UX
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
online-go/online-go.com#4000 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/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 75/100
SnosMe/awakened-poe-trade#1976 ·
-
[BUG]Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
jonp-h/TillerQuest#319 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
terrazzoapp/terrazzo#902 ·