datatracker
datatracker copied to clipboard
draft_aliases API may return same draft more than once
Describe the issue
The draft aliases update cron job is consistently failing its run shortly after midnight, US Pacific time. This is happening because at least one draft that expired the day of the run is listed twice in the alias list. This arises because the hourly cron job and the datatracker's daily expire_ids_task
both run at the same time.
In the draft_aliases
view, aliases are enumerated via code
active_drafts = drafts.filter(states=active_state)
for this_draft in active_drafts:
# [yield each alias for the draft]
inactive_recent_drafts = (
drafts.exclude(states=active_state)
.filter(expires__gte=show_since)
# [additional annotation]
)
)
for this_draft in inactive_recent_drafts:
# [yield each alias for the draft]
(square bracket comments indicate my trimming to simplify the structure)
The expire_ids_task
is expiring drafts between the loops over active and inactive drafts, so any newly expired drafts show up in both lists.
Probably the easiest fix is to remember which drafts were reported as active and then filter these out of the inactive ones rather than newly examining their state in the second loop.
In the immediate term, we probably ought to move the draft alias cron job's run time away from the celery task's run time.
Code of Conduct
- [X] I agree to follow the IETF's Code of Conduct