Upcoming papers sync can run twice at once and duplicate or empty the list
维护者通常 4 天内回复
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- mongodb, typescript
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- TypeScript
- 星标
- 23
- 派生
- 67
- 平均合并
- 2 天 17 小时
- 30 天内合并 PR
- 7
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
CodeChefVIT/papers-codechef 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
CodeChefVIT/papers-codechef#577 ·
维护者通常 4 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
CodeChefVIT/papers-codechef#552 · 1 条评论 · 1 个 reaction ·
维护者通常 4 天内回复
-
/api/upcoming-papers Throws 404 When No Exams are Active可能已有人在做 @Dx-Alz-xD 于 16 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
CodeChefVIT/papers-codechef#549 · 1 个 reaction ·
维护者通常 4 天内回复
-
难度 3/5 1-2 天 新手友好度 69/100
CodeChefVIT/papers-codechef#576 ·
维护者通常 4 天内回复
-
难度 3/5 1-2 天 新手友好度 64/100
CodeChefVIT/papers-codechef#575 ·
维护者通常 4 天内回复
查看 CodeChefVIT/papers-codechef 的全部 Issue
相似的 Issue
-
enhancement UX
难度 2/5 1-3 小时 新手友好度 67/100
online-go/online-go.com#4000 ·
维护者通常 1 天内回复
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
SnosMe/awakened-poe-trade#1976 ·
-
[BUG]未关闭bug
难度 2/5 1-3 小时 新手友好度 63/100
jonp-h/TillerQuest#319 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
terrazzoapp/terrazzo#902 ·