Upcoming papers sync can run twice at once and duplicate or empty the list
Mantenedores costumam responder em até 4 dias
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 25/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Estagnada
- Stack de tecnologia
- mongodb, typescript
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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
- Linguagem predominante
- TypeScript
- Estrelas
- 23
- Forks
- 67
- Merge médio
- 2d 17h
- PRs com merge (30d)
- 7
Preparar o ambiente
- Inclui um Dockerfile ou arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de CodeChefVIT/papers-codechef
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
CodeChefVIT/papers-codechef#577 ·
Mantenedores costumam responder em até 4 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
CodeChefVIT/papers-codechef#552 · 1 comentário · 1 reação ·
Mantenedores costumam responder em até 4 dias
-
/api/upcoming-papers Throws 404 When No Exams are ActiveTalvez já em andamento @Dx-Alz-xD assumiu há 16 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
CodeChefVIT/papers-codechef#549 · 1 reação ·
Mantenedores costumam responder em até 4 dias
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 69/100
CodeChefVIT/papers-codechef#576 ·
Mantenedores costumam responder em até 4 dias
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 64/100
CodeChefVIT/papers-codechef#575 ·
Mantenedores costumam responder em até 4 dias
Todas as issues de CodeChefVIT/papers-codechef
Issues semelhantes
-
enhancement UX
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 67/100
online-go/online-go.com#4000 ·
Mantenedores costumam responder em até 1 dia
-
enhancement good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
SnosMe/awakened-poe-trade#1976 ·
-
[BUG]Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 63/100
jonp-h/TillerQuest#319 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
terrazzoapp/terrazzo#902 ·