(_ context.Context, jobID int64)
| 207 | } |
| 208 | |
| 209 | func (s *sqlDatabase) BreakLockJobIsQueued(_ context.Context, jobID int64) error { |
| 210 | var asParams params.Job |
| 211 | |
| 212 | err := s.conn.Transaction(func(tx *gorm.DB) error { |
| 213 | var workflowJob WorkflowJob |
| 214 | q := tx.Clauses(clause.Locking{Strength: "UPDATE"}).Preload("Instance").Where("workflow_job_id = ? and status = ?", jobID, params.JobStatusQueued).First(&workflowJob) |
| 215 | |
| 216 | if q.Error != nil { |
| 217 | if errors.Is(q.Error, gorm.ErrRecordNotFound) { |
| 218 | return nil |
| 219 | } |
| 220 | return fmt.Errorf("error fetching job: %w", q.Error) |
| 221 | } |
| 222 | |
| 223 | if workflowJob.LockedBy == uuid.Nil { |
| 224 | // Job is already unlocked. |
| 225 | return nil |
| 226 | } |
| 227 | |
| 228 | workflowJob.LockedBy = uuid.Nil |
| 229 | if err := tx.Save(&workflowJob).Error; err != nil { |
| 230 | return fmt.Errorf("error saving job: %w", err) |
| 231 | } |
| 232 | |
| 233 | var err error |
| 234 | asParams, err = sqlWorkflowJobToParamsJob(workflowJob) |
| 235 | if err != nil { |
| 236 | return fmt.Errorf("error converting job: %w", err) |
| 237 | } |
| 238 | return nil |
| 239 | }) |
| 240 | if err != nil { |
| 241 | return err |
| 242 | } |
| 243 | |
| 244 | if asParams.ID != 0 { |
| 245 | s.sendNotify(common.JobEntityType, common.UpdateOperation, asParams) |
| 246 | } |
| 247 | return nil |
| 248 | } |
| 249 | |
| 250 | func (s *sqlDatabase) UnlockJob(_ context.Context, jobID int64, entityID string) error { |
| 251 | var asParams params.Job |
nothing calls this directly
no test coverage detected