Upcoming papers sync can run twice at once and duplicate or empty the list
I maintainer di solito rispondono entro 4 giorni
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- mongodb, typescript
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- TypeScript
- Stelle
- 23
- Fork
- 67
- Merge medio
- 2g 17h
- PR unite (30g)
- 7
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di CodeChefVIT/papers-codechef
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
CodeChefVIT/papers-codechef#577 ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
CodeChefVIT/papers-codechef#552 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 4 giorni
-
/api/upcoming-papers Throws 404 When No Exams are ActiveForse già presa @Dx-Alz-xD l’ha presa 16 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
CodeChefVIT/papers-codechef#549 · 1 reazione ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 69/100
CodeChefVIT/papers-codechef#576 ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 64/100
CodeChefVIT/papers-codechef#575 ·
I maintainer di solito rispondono entro 4 giorni
Tutte le issue di CodeChefVIT/papers-codechef
Issue simili
-
enhancement UX
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
online-go/online-go.com#4000 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
SnosMe/awakened-poe-trade#1976 ·
-
[BUG]Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
jonp-h/TillerQuest#319 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
terrazzoapp/terrazzo#902 ·