Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
sync job updates timestamps
  • Loading branch information
owen-d committed Dec 10, 2024
commit d14f9d63c61a1e5bc11e9444ac96c2b17cdb47a2
14 changes: 12 additions & 2 deletions pkg/blockbuilder/scheduler/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,22 @@ func (q *JobQueue) GetStatus(id string) (types.JobStatus, bool) {
return status, ok
}

// SyncJob registers a job as in-progress, used for restoring state after scheduler restarts
// SyncJob registers a job as in-progress or updates its UpdateTime if already in progress
func (q *JobQueue) SyncJob(jobID string, job *types.Job) {
// Check if job exists and is in progress
if status, exists := q.Exists(job); exists && status == types.JobStatusInProgress {
q.mu.Lock()
if existingJob, ok := q.inProgress[jobID]; ok {
existingJob.UpdateTime = time.Now()
}
q.mu.Unlock()
return
}

q.mu.Lock()
defer q.mu.Unlock()

// Add directly to in-progress
// Add new job to in-progress
jobMeta := &JobWithMetadata{
Job: job,
Priority: 0, // Priority is not known in this case
Expand Down