Skip to content

Commit

Permalink
Make manage submissions rejudging idempotent; fixes DMOJ#1009 (DMOJ#1127
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Xyene authored Oct 21, 2019
1 parent 6e80bb2 commit d6cf3d7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion judge/bridge/judgelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,14 @@ def check_priority(self, priority):
def judge(self, id, problem, language, source, priority):
with self.lock:
if id in self.submission_map or id in self.node_map:
logger.warning('Already judging? %d', id)
# Already judging, don't queue again. This can happen during batch rejudges, rejudges should be
# idempotent.
return

candidates = [judge for judge in self.judges if not judge.working and judge.can_judge(problem, language)]
logger.info('Free judges: %d', len(candidates))
if candidates:
# Schedule the submission on the judge reporting least load.
judge = min(candidates, key=attrgetter('load'))
logger.info('Dispatched submission %d to: %s', id, judge.name)
self.submission_map[id] = judge
Expand Down
1 change: 1 addition & 0 deletions judge/models/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Submission(models.Model):
('CE', _('Compile Error')),
('AB', _('Aborted')),
)
IN_PROGRESS_GRADING_STATUS = ('QU', 'P', 'G')
RESULT = SUBMISSION_RESULT
USER_DISPLAY_CODES = {
'AC': _('Accepted'),
Expand Down
1 change: 1 addition & 0 deletions judge/tasks/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def apply_submission_filter(queryset, id_range, languages, results):
queryset = queryset.filter(language_id__in=languages)
if results:
queryset = queryset.filter(result__in=results)
queryset = queryset.exclude(status__in=Submission.IN_PROGRESS_GRADING_STATUS)
return queryset


Expand Down

0 comments on commit d6cf3d7

Please sign in to comment.