Skip to content

Commit

Permalink
state: Avoid deduplicating jobs on enqueuing
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko committed Aug 9, 2022
1 parent e71a213 commit 1ac6cae
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions internal/state/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,6 @@ const (
)

func (js *JobStore) EnqueueJob(newJob job.Job) (job.ID, error) {
jobID, queued, err := js.jobExists(newJob, StateQueued)
if err != nil {
return "", err
}
if queued {
return jobID, nil
}

jobID, running, err := js.jobExists(newJob, StateRunning)
if err != nil {
return "", err
}
if running {
return jobID, nil
}

txn := js.db.Txn(true)
defer txn.Abort()

Expand All @@ -98,7 +82,7 @@ func (js *JobStore) EnqueueJob(newJob job.Job) (job.ID, error) {
State: StateQueued,
}

err = txn.Insert(js.tableName, sJob)
err := txn.Insert(js.tableName, sJob)
if err != nil {
return "", fmt.Errorf("failed to insert new job: %w", err)
}
Expand Down

0 comments on commit 1ac6cae

Please sign in to comment.