Overview
Thequeue_controller provides administrative interfaces for managing the submission judging queue. It allows administrators to view queue status, manually trigger queue processing, unlock stuck items, and clear the entire queue.
Constructor
auth- Requires user authentication
Methods
index()
- Admin and head_instructor only
- Aborts with 404 for other roles
- All queue items (latest first)
- Related submission data for each item
- Processing status (locked/unlocked)
- Queue type (judge/rejudge)
/queue (GET)
Example from controller:
work()
- Admin and head_instructor only
- Aborts with 404 for other roles
- Calls
Queue_item::work()static method - Processes next available unlocked queue item
- Runs judging for associated submission
/queue (POST)
Example from controller:
unlock()
Queue item ID to unlock
- Admin and head_instructor only
- Aborts with 403 for other roles
/queue/{item}/unlock (POST)
Example from controller:
empty()
- Admin and head_instructor only
- Aborts with 403 for other roles
/queue/empty (POST)
Example from controller:
Queue System Overview
Queue Item States
Unlocked (processid = NULL)- Item is available for processing
- Worker can pick it up
- Item is being processed by a worker
- processid contains the worker’s process ID
- Other workers skip this item
- Item is locked but worker has crashed/died
- processid points to non-existent process
- Requires manual unlock
Queue Processing Flow
-
Submission Created
- User submits code
- Queue item created with type ‘judge’
- Automatic processing triggered
-
Worker Picks Item
- Worker calls
Queue_item::work() - Finds first unlocked item
- Locks item with process ID
- Worker calls
-
Judging Execution
- Worker runs test cases
- Updates submission status
- Writes results to files
-
Completion
- Queue item deleted
- Submission marked complete
- Scoreboard updated if final submission
Queue Types
judge- New submission from user
- First time judging this submission
- Created by submission_controller::store()
- Re-evaluation of existing submission
- Created by submission_controller::rejudge()
- Used when test cases or time limits change
Queue Management Scenarios
Scenario 1: Queue Not Processing
Symptoms:- Submissions stuck in PENDING status
- Queue items accumulating
- No recent completion activity
- Check queue page
- Look for locked items with old timestamps
- Check if worker processes exist
- Kill hung worker processes (if any)
- Unlock stuck items via UI
- Click “Work” to manually trigger processing
- Check queue settings (concurrent workers)
Scenario 2: Queue Overflow
Symptoms:- Hundreds/thousands of queue items
- System slow or unresponsive
- Students reporting long wait times
- Check queue page for item count
- Review recent activity (exam? deadline?)
- Check server resources (CPU, memory)
- Increase concurrent workers in settings
- Consider clearing old queue items
- Restart queue workers
- Add more worker servers if needed
Scenario 3: Corrupt Queue
Symptoms:- Workers crashing repeatedly
- Error messages in logs
- Items processing but failing
- Review error logs
- Check specific submission causing issues
- Verify test case files exist
- Empty entire queue using “Empty” button
- Fix underlying issue (test cases, permissions, etc.)
- Rejudge affected submissions
Administrative Best Practices
Regular Monitoring
- Check queue page daily during active periods
- Set up alerts for queue depth > threshold
- Monitor worker process health
- Review completion rates
Maintenance Windows
- Schedule during low-activity periods
- Announce to users in advance
- Empty queue before major updates
- Test with small queue after changes
Disaster Recovery
- Document queue clearing procedures
- Keep list of recent submission IDs
- Have rejudge scripts ready
- Maintain backup of test cases
Related Components
Queue_item Model
Fields:id- Primary keysubmission_id- Foreign key to submissionsprocessid- Lock indicator (NULL = unlocked)type- Queue type (judge/rejudge)created_at- Timestampupdated_at- Timestamp
work()- Process next itemadd_and_process()- Add item and trigger processingadd_not_process()- Add item without triggering
Submission Model
Queue items reference submissions:- Each queue item processes one submission
- Submission status updated during processing
- Results written to submission’s directory
Settings
concurent_queue_process- Number of simultaneous queue workers
- Default: 2
- Increase for high-load periods
- Adjust based on server capacity
Routes Summary
| Method | Route | Action | Description |
|---|---|---|---|
| GET | /queue | index() | View queue status |
| POST | /queue | work() | Process next item |
| POST | /queue/{item}/unlock | unlock() | Unlock stuck item |
| POST | /queue/empty | empty() | Clear entire queue |
Related Models
- Queue_item: Queue item records
- Submission: Submissions being judged
- Assignment: Assignment context
- Problem: Problem being judged
- Setting: Queue configuration

